diff options
| author | qwasdrizzel <145519042+qwasdrizzel@users.noreply.github.com> | 2026-03-16 21:44:26 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-16 21:44:26 -0500 |
| commit | ce739f6045ec72127491286ea3f3f21e537c1b55 (patch) | |
| tree | f33bd42a47c1b4a7b2153a7fb77127ee3b407db9 /Minecraft.Client/Common/Consoles_App.cpp | |
| parent | 255a18fe8e9b57377975f82e2b227afe2a12eda0 (diff) | |
| parent | 5a59f5d146b43811dde6a5a0245ee9875d7b5cd1 (diff) | |
Merge branch 'smartcmd:main' into main
Diffstat (limited to 'Minecraft.Client/Common/Consoles_App.cpp')
| -rw-r--r-- | Minecraft.Client/Common/Consoles_App.cpp | 1178 |
1 files changed, 620 insertions, 558 deletions
diff --git a/Minecraft.Client/Common/Consoles_App.cpp b/Minecraft.Client/Common/Consoles_App.cpp index 3aae68d2..0a2fd159 100644 --- a/Minecraft.Client/Common/Consoles_App.cpp +++ b/Minecraft.Client/Common/Consoles_App.cpp @@ -38,6 +38,9 @@ #include "GameRules\ConsoleSchematicFile.h" #include "..\User.h" #include "..\..\Minecraft.World\LevelData.h" +#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD) +#include "..\..\Minecraft.Server\ServerLogManager.h" +#endif #include "..\..\Minecraft.World\net.minecraft.world.entity.player.h" #include "..\EntityRenderDispatcher.h" #include "..\..\Minecraft.World\compression.h" @@ -100,7 +103,7 @@ CMinecraftApp::CMinecraftApp() { m_eTMSAction[i]=eTMSAction_Idle; m_eXuiAction[i]=eAppAction_Idle; - m_eXuiActionParam[i] = NULL; + m_eXuiActionParam[i] = nullptr; //m_dwAdditionalModelParts[i] = 0; if(FAILED(XUserGetSigninInfo(i,XUSER_GET_SIGNIN_INFO_OFFLINE_XUID_ONLY ,&m_currentSigninInfo[i]))) @@ -157,9 +160,9 @@ CMinecraftApp::CMinecraftApp() // m_bRead_TMS_XUIDS_XML=false; // m_bRead_TMS_DLCINFO_XML=false; - m_pDLCFileBuffer=NULL; + m_pDLCFileBuffer=nullptr; m_dwDLCFileSize=0; - m_pBannedListFileBuffer=NULL; + m_pBannedListFileBuffer=nullptr; m_dwBannedListFileSize=0; m_bDefaultCapeInstallAttempted=false; @@ -207,7 +210,7 @@ CMinecraftApp::CMinecraftApp() #ifdef _XBOX // m_bTransferSavesToXboxOne=false; // m_uiTransferSlotC=5; -#endif +#endif #if (defined _CONTENT_PACAKGE) || (defined _XBOX) m_bUseDPadForDebug = false; @@ -224,7 +227,7 @@ CMinecraftApp::CMinecraftApp() for(int i=0;i<XUSER_MAX_COUNT;i++) { - m_vBannedListA[i] = new vector<PBANNEDLISTDATA>; + m_vBannedListA[i] = new vector<PBANNEDLISTDATA>; } LocaleAndLanguageInit(); @@ -240,12 +243,21 @@ 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); + va_list ap; + va_start(ap, szFormat); +#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD) + // Dedicated server routes client debug spew through ServerLogger so CLI output stays prompt-safe. + if (ServerRuntime::ServerLogManager::ShouldForwardClientDebugLogs()) + { + ServerRuntime::ServerLogManager::ForwardClientAppDebugLogV(szFormat, ap); + va_end(ap); + return; + } +#endif + char buf[1024]; + vsnprintf(buf, sizeof(buf), szFormat, ap); + va_end(ap); + OutputDebugStringA(buf); #endif } @@ -253,53 +265,62 @@ void CMinecraftApp::DebugPrintf(const char *szFormat, ...) void CMinecraftApp::DebugPrintf(int user, const char *szFormat, ...) { #ifndef _FINAL_BUILD - if(user == USER_NONE) - return; - char buf[1024]; - va_list ap; - va_start(ap, szFormat); - vsnprintf(buf, sizeof(buf), szFormat, ap); - va_end(ap); + if(user == USER_NONE) + return; + va_list ap; + va_start(ap, szFormat); +#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD) + // Dedicated server routes client debug spew through ServerLogger so CLI output stays prompt-safe. + if (ServerRuntime::ServerLogManager::ShouldForwardClientDebugLogs()) + { + ServerRuntime::ServerLogManager::ForwardClientUserDebugLogV(user, szFormat, ap); + va_end(ap); + return; + } +#endif + char buf[1024]; + vsnprintf(buf, sizeof(buf), szFormat, ap); + va_end(ap); #ifdef __PS3__ - unsigned int writelen; - sys_tty_write(SYS_TTYP_USER1 + ( user - 1 ), buf, strlen(buf), &writelen ); + unsigned int writelen; + sys_tty_write(SYS_TTYP_USER1 + ( user - 1 ), buf, strlen(buf), &writelen ); #elif defined __PSVITA__ - switch(user) - { - case 0: - { - SceUID tty2 = sceIoOpen("tty2:", SCE_O_WRONLY, 0); - if(tty2>=0) - { - std::string string1(buf); - sceIoWrite(tty2, string1.c_str(), string1.length()); - sceIoClose(tty2); - } - } - break; - case 1: - { - SceUID tty3 = sceIoOpen("tty3:", SCE_O_WRONLY, 0); - if(tty3>=0) - { - std::string string1(buf); - sceIoWrite(tty3, string1.c_str(), string1.length()); - sceIoClose(tty3); - } - } - break; - default: - OutputDebugStringA(buf); - break; - } + switch(user) + { + case 0: + { + SceUID tty2 = sceIoOpen("tty2:", SCE_O_WRONLY, 0); + if(tty2>=0) + { + std::string string1(buf); + sceIoWrite(tty2, string1.c_str(), string1.length()); + sceIoClose(tty2); + } + } + break; + case 1: + { + SceUID tty3 = sceIoOpen("tty3:", SCE_O_WRONLY, 0); + if(tty3>=0) + { + std::string string1(buf); + sceIoWrite(tty3, string1.c_str(), string1.length()); + sceIoClose(tty3); + } + } + break; + default: + OutputDebugStringA(buf); + break; + } #else - OutputDebugStringA(buf); + OutputDebugStringA(buf); #endif #ifndef _XBOX - if(user == USER_UI) - { - ui.logDebugString(buf); - } + if(user == USER_UI) + { + ui.logDebugString(buf); + } #endif #endif } @@ -331,7 +352,7 @@ void CMinecraftApp::SetAction(int iPad, eXuiAction action, LPVOID param) m_eXuiAction[iPad]=action; m_eXuiActionParam[iPad] = param; } -} +} bool CMinecraftApp::IsAppPaused() { @@ -367,7 +388,7 @@ 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<GAME_DEFINED_PROFILE_DATA_BYTES;i++) @@ -456,7 +477,7 @@ bool CMinecraftApp::LoadCrafting3x3Menu(int iPad,shared_ptr<LocalPlayer> player, CraftingPanelScreenInput* initData = new CraftingPanelScreenInput(); initData->player = player; - initData->iContainerType=RECIPE_TYPE_3x3; + initData->iContainerType=RECIPE_TYPE_3x3; initData->iPad = iPad; initData->x = x; initData->y = y; @@ -589,7 +610,7 @@ bool CMinecraftApp::LoadContainerMenu(int iPad,shared_ptr<Container> inventory, initData->container = container; initData->iPad = iPad; - // Load the scene. + // Load the scene. if(app.GetLocalPlayerCount()>1) { initData->bSplitscreen=true; @@ -763,7 +784,7 @@ bool CMinecraftApp::LoadBeaconMenu(int iPad ,shared_ptr<Inventory> inventory, sh #ifdef _WINDOWS64 static void Win64_GetSettingsPath(char *outPath, DWORD size) { - GetModuleFileNameA(NULL, outPath, size); + GetModuleFileNameA(nullptr, outPath, size); char *lastSlash = strrchr(outPath, '\\'); if (lastSlash) *(lastSlash + 1) = '\0'; strncat_s(outPath, size, "settings.dat", _TRUNCATE); @@ -773,7 +794,7 @@ static void Win64_SaveSettings(GAME_SETTINGS *gs) if (!gs) return; char filePath[MAX_PATH] = {}; Win64_GetSettingsPath(filePath, MAX_PATH); - FILE *f = NULL; + FILE *f = nullptr; if (fopen_s(&f, filePath, "wb") == 0 && f) { fwrite(gs, sizeof(GAME_SETTINGS), 1, f); @@ -785,7 +806,7 @@ static void Win64_LoadSettings(GAME_SETTINGS *gs) if (!gs) return; char filePath[MAX_PATH] = {}; Win64_GetSettingsPath(filePath, MAX_PATH); - FILE *f = NULL; + FILE *f = nullptr; if (fopen_s(&f, filePath, "rb") == 0 && f) { GAME_SETTINGS temp = {}; @@ -803,7 +824,7 @@ void CMinecraftApp::InitGameSettings() #if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__) GameSettingsA[i]=(GAME_SETTINGS *)StorageManager.GetGameDefinedProfileData(i); #else - GameSettingsA[i]=(GAME_SETTINGS *)ProfileManager.GetGameDefinedProfileData(i); + GameSettingsA[i]=static_cast<GAME_SETTINGS *>(ProfileManager.GetGameDefinedProfileData(i)); #endif // clear the flag to say the settings have changed GameSettingsA[i]->bSettingsChanged=false; @@ -835,10 +856,12 @@ int CMinecraftApp::SetDefaultOptions(C_4JProfile::PROFILESETTINGS *pSettings,con { SetGameSettings(iPad,eGameSetting_MusicVolume,DEFAULT_VOLUME_LEVEL); SetGameSettings(iPad,eGameSetting_SoundFXVolume,DEFAULT_VOLUME_LEVEL); + SetGameSettings(iPad,eGameSetting_RenderDistance,16); SetGameSettings(iPad,eGameSetting_Gamma,50); + SetGameSettings(iPad,eGameSetting_FOV,0); // 4J-PB - Don't reset the difficult level if we're in-game - if(Minecraft::GetInstance()->level==NULL) + if(Minecraft::GetInstance()->level==nullptr) { app.DebugPrintf("SetDefaultOptions - Difficulty = 1\n"); SetGameSettings(iPad,eGameSetting_Difficulty,1); @@ -912,7 +935,7 @@ int CMinecraftApp::SetDefaultOptions(C_4JProfile::PROFILESETTINGS *pSettings,con // 4J-JEV: We cannot change these in-game, as they could affect localised strings and font. // XB1: Fix for #172947 - Content: Gameplay: While playing in language different form system default one and resetting options to their defaults in active gameplay causes in-game language to change and HUD to disappear - if (!app.GetGameStarted()) + if (!app.GetGameStarted()) { GameSettingsA[iPad]->ucLanguage = MINECRAFT_LANGUAGE_DEFAULT; // use the system language GameSettingsA[iPad]->ucLocale = MINECRAFT_LANGUAGE_DEFAULT; // use the system locale @@ -933,7 +956,7 @@ int CMinecraftApp::DefaultOptionsCallback(LPVOID pParam,C4JStorage::PROFILESETTI int CMinecraftApp::DefaultOptionsCallback(LPVOID pParam,C_4JProfile::PROFILESETTINGS *pSettings, const int iPad) #endif { - CMinecraftApp *pApp=(CMinecraftApp *)pParam; + CMinecraftApp *pApp=static_cast<CMinecraftApp *>(pParam); // flag the default options to be set @@ -1022,7 +1045,7 @@ int CMinecraftApp::OldProfileVersionCallback(LPVOID pParam,unsigned char *pucDat 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 @@ -1068,7 +1091,7 @@ int CMinecraftApp::OldProfileVersionCallback(LPVOID pParam,unsigned char *pucDat break; case PROFILE_VERSION_3: - { + { GAME_SETTINGS *pGameSettings=(GAME_SETTINGS *)pucData; pGameSettings->uiBitmaskValues=0L; // reset pGameSettings->uiBitmaskValues|=GAMESETTING_CLOUDS; //eGameSetting_Clouds - on @@ -1202,7 +1225,7 @@ int CMinecraftApp::OldProfileVersionCallback(LPVOID pParam,unsigned char *pucDat break; case PROFILE_VERSION_7: - { + { GAME_SETTINGS *pGameSettings=(GAME_SETTINGS *)pucData; // reset the display new message counter pGameSettings->uiBitmaskValues|=GAMESETTING_DISPLAYUPDATEMSG; //eGameSetting_DisplayUpdateMessage (counter) @@ -1225,7 +1248,7 @@ int CMinecraftApp::OldProfileVersionCallback(LPVOID pParam,unsigned char *pucDat 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) @@ -1243,7 +1266,7 @@ int CMinecraftApp::OldProfileVersionCallback(LPVOID pParam,unsigned char *pucDat break; case PROFILE_VERSION_9: // PS3DEC13 - { + { GAME_SETTINGS *pGameSettings=(GAME_SETTINGS *)pucData; pGameSettings->uiBitmaskValues|=GAMESETTING_DISPLAYUPDATEMSG; //eGameSetting_DisplayUpdateMessage (counter) pGameSettings->uiBitmaskValues&=~GAMESETTING_PS3EULAREAD; //eGameSetting_PS3_EULA_Read - off @@ -1254,7 +1277,7 @@ int CMinecraftApp::OldProfileVersionCallback(LPVOID pParam,unsigned char *pucDat } break; case PROFILE_VERSION_10: - { + { GAME_SETTINGS *pGameSettings=(GAME_SETTINGS *)pucData; pGameSettings->uiBitmaskValues|=GAMESETTING_DISPLAYUPDATEMSG; //eGameSetting_DisplayUpdateMessage (counter) pGameSettings->ucLanguage = MINECRAFT_LANGUAGE_DEFAULT; // use the system language @@ -1273,7 +1296,7 @@ int CMinecraftApp::OldProfileVersionCallback(LPVOID pParam,unsigned char *pucDat } 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 @@ -1329,7 +1352,9 @@ void CMinecraftApp::ApplyGameSettingsChanged(int iPad) { ActionGameSettings(iPad,eGameSetting_MusicVolume ); ActionGameSettings(iPad,eGameSetting_SoundFXVolume ); + ActionGameSettings(iPad,eGameSetting_RenderDistance ); ActionGameSettings(iPad,eGameSetting_Gamma ); + ActionGameSettings(iPad,eGameSetting_FOV ); ActionGameSettings(iPad,eGameSetting_Difficulty ); ActionGameSettings(iPad,eGameSetting_Sensitivity_InGame ); ActionGameSettings(iPad,eGameSetting_ViewBob ); @@ -1368,28 +1393,45 @@ void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal) case eGameSetting_MusicVolume: if(iPad==ProfileManager.GetPrimaryPad()) { - pMinecraft->options->set(Options::Option::MUSIC,((float)GameSettingsA[iPad]->ucMusicVolume)/100.0f); + pMinecraft->options->set(Options::Option::MUSIC,static_cast<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); - } + case eGameSetting_SoundFXVolume: + if (iPad == ProfileManager.GetPrimaryPad()) + { + pMinecraft->options->set(Options::Option::SOUND, static_cast<float>(GameSettingsA[iPad]->ucSoundFXVolume) / 100.0f); + } + break; + case eGameSetting_RenderDistance: + if (iPad == ProfileManager.GetPrimaryPad()) + { + int dist = (GameSettingsA[iPad]->uiBitmaskValues >> 16) & 0xFF; + + int level = UIScene_SettingsGraphicsMenu::DistanceToLevel(dist); + pMinecraft->options->set(Options::Option::RENDER_DISTANCE, 3 - level); + }; break; case eGameSetting_Gamma: if(iPad==ProfileManager.GetPrimaryPad()) { #if defined(_WIN64) || defined(_WINDOWS64) - pMinecraft->options->set(Options::Option::GAMMA, ((float)GameSettingsA[iPad]->ucGamma) / 100.0f); + pMinecraft->options->set(Options::Option::GAMMA, static_cast<float>(GameSettingsA[iPad]->ucGamma) / 100.0f); #else // ucGamma range is 0-100, UpdateGamma is 0 - 32768 float fVal=((float)GameSettingsA[iPad]->ucGamma)*327.68f; RenderManager.UpdateGamma((unsigned short)fVal); #endif - } + } break; + case eGameSetting_FOV: + if(iPad==ProfileManager.GetPrimaryPad()) + { + float fovDeg = 70.0f + (float)GameSettingsA[iPad]->ucFov * 40.0f / 100.0f; + pMinecraft->gameRenderer->SetFovVal(fovDeg); + pMinecraft->options->set(Options::Option::FOV, (float)GameSettingsA[iPad]->ucFov / 100.0f); + } + break; case eGameSetting_Difficulty: if(iPad==ProfileManager.GetPrimaryPad()) { @@ -1400,7 +1442,7 @@ void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal) app.SetGameHostOption(eGameHostOption_Difficulty,pMinecraft->options->difficulty); // send this to the other players if we are in-game - bool bInGame=pMinecraft->level!=NULL; + bool bInGame=pMinecraft->level!=nullptr; // 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())) @@ -1417,7 +1459,7 @@ void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal) 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); + pMinecraft->options->set(Options::Option::SENSITIVITY,static_cast<float>(GameSettingsA[iPad]->ucSensitivity)/100.0f); //InputManager.SetJoypadSensitivity(iPad,((float)GameSettingsA[iPad]->ucSensitivity)/100.0f); break; @@ -1464,7 +1506,7 @@ void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal) break; case eGameSetting_GamertagsVisible: { - bool bInGame=pMinecraft->level!=NULL; + bool bInGame=pMinecraft->level!=nullptr; // Game Host only if(bInGame && g_NetworkManager.IsHost() && (iPad==ProfileManager.GetPrimaryPad())) @@ -1493,7 +1535,7 @@ void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal) case eGameSetting_DisplaySplitscreenGamertags: for( BYTE idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if(pMinecraft->localplayers[idx] != NULL) + if(pMinecraft->localplayers[idx] != nullptr) { if(pMinecraft->localplayers[idx]->m_iScreenSection==C4JRender::VIEWPORT_TYPE_FULLSCREEN) { @@ -1537,19 +1579,17 @@ void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal) 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_BedrockFog: + { + bool bInGame = pMinecraft->level != nullptr; + + if (bInGame && g_NetworkManager.IsHost() && (iPad == ProfileManager.GetPrimaryPad())) + { + 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; @@ -1596,7 +1636,7 @@ void CMinecraftApp::SetPlayerSkin(int iPad,DWORD dwSkinId) TelemetryManager->RecordSkinChanged(iPad, GameSettingsA[iPad]->dwSelectedSkin); - if(Minecraft::GetInstance()->localplayers[iPad]!=NULL) Minecraft::GetInstance()->localplayers[iPad]->setAndBroadcastCustomSkin(dwSkinId); + if(Minecraft::GetInstance()->localplayers[iPad]!=nullptr) Minecraft::GetInstance()->localplayers[iPad]->setAndBroadcastCustomSkin(dwSkinId); } @@ -1608,8 +1648,8 @@ wstring CMinecraftApp::GetPlayerSkinName(int iPad) DWORD 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; + DLCPack *Pack=nullptr; + DLCSkinFile *skinFile=nullptr; DWORD dwSkin=GameSettingsA[iPad]->dwSelectedSkin; wchar_t chars[256]; @@ -1618,7 +1658,7 @@ DWORD CMinecraftApp::GetPlayerSkinId(int iPad) // 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); + Pack=app.m_dlcManager.getPackContainingSkin(chars); if(Pack) { @@ -1664,7 +1704,7 @@ void CMinecraftApp::SetPlayerCape(int iPad,DWORD dwCapeId) //SentientManager.RecordSkinChanged(iPad, GameSettingsA[iPad]->dwSelectedSkin); - if(Minecraft::GetInstance()->localplayers[iPad]!=NULL) Minecraft::GetInstance()->localplayers[iPad]->setAndBroadcastCustomCape(dwCapeId); + if(Minecraft::GetInstance()->localplayers[iPad]!=nullptr) Minecraft::GetInstance()->localplayers[iPad]->setAndBroadcastCustomCape(dwCapeId); } wstring CMinecraftApp::GetPlayerCapeName(int iPad) @@ -1697,7 +1737,7 @@ unsigned char CMinecraftApp::GetPlayerFavoriteSkinsPos(int iPad) void CMinecraftApp::SetPlayerFavoriteSkinsPos(int iPad, int iPos) { - GameSettingsA[iPad]->ucCurrentFavoriteSkinPos=(unsigned char)iPos; + GameSettingsA[iPad]->ucCurrentFavoriteSkinPos=static_cast<unsigned char>(iPos); GameSettingsA[iPad]->bSettingsChanged = true; } @@ -1734,7 +1774,7 @@ void CMinecraftApp::ValidateFavoriteSkins(int iPad) // Also check they haven't reverted to a trial pack DLCPack *pDLCPack=app.m_dlcManager.getPackContainingSkin(chars); - if(pDLCPack!=NULL) + if(pDLCPack!=nullptr) { // 4J-PB - We should let players add the free skins to their favourites as well! //DLCFile *pDLCFile=pDLCPack->getFile(DLCManager::e_DLCType_Skin,chars); @@ -1742,7 +1782,7 @@ void CMinecraftApp::ValidateFavoriteSkins(int iPad) if( pDLCPack->hasPurchasedFile(DLCManager::e_DLCType_Skin, L"") || (pSkinFile && pSkinFile->isFree())) { - GameSettingsA[iPad]->uiFavoriteSkinA[uiValidSkin++]=GameSettingsA[iPad]->uiFavoriteSkinA[i]; + GameSettingsA[iPad]->uiFavoriteSkinA[uiValidSkin++]=GameSettingsA[iPad]->uiFavoriteSkinA[i]; } } } @@ -1774,14 +1814,14 @@ unsigned int CMinecraftApp::GetMashupPackWorlds(int iPad) void CMinecraftApp::SetMinecraftLanguage(int iPad, unsigned char ucLanguage) { - GameSettingsA[iPad]->ucLanguage = ucLanguage; + GameSettingsA[iPad]->ucLanguage = ucLanguage; GameSettingsA[iPad]->bSettingsChanged = true; } unsigned char CMinecraftApp::GetMinecraftLanguage(int iPad) { // if there are no game settings read yet, return the default language - if(GameSettingsA[iPad]==NULL) + if(GameSettingsA[iPad]==nullptr) { return 0; } @@ -1793,14 +1833,14 @@ unsigned char CMinecraftApp::GetMinecraftLanguage(int iPad) void CMinecraftApp::SetMinecraftLocale(int iPad, unsigned char ucLocale) { - GameSettingsA[iPad]->ucLocale = ucLocale; + GameSettingsA[iPad]->ucLocale = ucLocale; GameSettingsA[iPad]->bSettingsChanged = true; } unsigned char CMinecraftApp::GetMinecraftLocale(int iPad) { // if there are no game settings read yet, return the default language - if(GameSettingsA[iPad]==NULL) + if(GameSettingsA[iPad]==nullptr) { return 0; } @@ -1834,10 +1874,21 @@ void CMinecraftApp::SetGameSettings(int iPad,eGameSetting eVal,unsigned char ucV if(iPad==ProfileManager.GetPrimaryPad()) { ActionGameSettings(iPad,eVal); - } + } GameSettingsA[iPad]->bSettingsChanged=true; } break; + case eGameSetting_RenderDistance: + { + unsigned int val = ucVal & 0xFF; + + GameSettingsA[iPad]->uiBitmaskValues &= ~(0xFF << 16); + GameSettingsA[iPad]->uiBitmaskValues |= val << 16; + if(iPad == ProfileManager.GetPrimaryPad()) + ActionGameSettings(iPad,eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } + break; case eGameSetting_Gamma: if(GameSettingsA[iPad]->ucGamma!=ucVal) { @@ -1849,6 +1900,17 @@ void CMinecraftApp::SetGameSettings(int iPad,eGameSetting eVal,unsigned char ucV GameSettingsA[iPad]->bSettingsChanged=true; } break; + case eGameSetting_FOV: + if(GameSettingsA[iPad]->ucFov!=ucVal) + { + GameSettingsA[iPad]->ucFov=ucVal; + if(iPad==ProfileManager.GetPrimaryPad()) + { + ActionGameSettings(iPad,eVal); + } + GameSettingsA[iPad]->bSettingsChanged=true; + } + break; case eGameSetting_Difficulty: if((GameSettingsA[iPad]->usBitmaskValues&0x03)!=(ucVal&0x03)) { @@ -2194,9 +2256,9 @@ void CMinecraftApp::SetGameSettings(int iPad,eGameSetting eVal,unsigned char ucV } ActionGameSettings(iPad,eVal); GameSettingsA[iPad]->bSettingsChanged=true; - } - break; - case eGameSetting_UISize: + } + break; + case eGameSetting_UISize: if((GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_UISIZE)!=((ucVal&0x03)<<11)) { GameSettingsA[iPad]->uiBitmaskValues&=~GAMESETTING_UISIZE; @@ -2208,7 +2270,7 @@ void CMinecraftApp::SetGameSettings(int iPad,eGameSetting eVal,unsigned char ucV GameSettingsA[iPad]->bSettingsChanged=true; } break; - case eGameSetting_UISizeSplitscreen: + case eGameSetting_UISizeSplitscreen: if((GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_UISIZE_SPLITSCREEN)!=((ucVal&0x03)<<13)) { GameSettingsA[iPad]->uiBitmaskValues&=~GAMESETTING_UISIZE_SPLITSCREEN; @@ -2233,8 +2295,8 @@ void CMinecraftApp::SetGameSettings(int iPad,eGameSetting eVal,unsigned char ucV } ActionGameSettings(iPad,eVal); GameSettingsA[iPad]->bSettingsChanged=true; - } - break; + } + break; case eGameSetting_PS3_EULA_Read: if((GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_PS3EULAREAD)!=(ucVal&0x01)<<16) { @@ -2248,8 +2310,8 @@ void CMinecraftApp::SetGameSettings(int iPad,eGameSetting eVal,unsigned char ucV } ActionGameSettings(iPad,eVal); GameSettingsA[iPad]->bSettingsChanged=true; - } - break; + } + break; case eGameSetting_PSVita_NetworkModeAdhoc: if((GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_PSVITANETWORKMODEADHOC)!=(ucVal&0x01)<<17) { @@ -2263,8 +2325,8 @@ void CMinecraftApp::SetGameSettings(int iPad,eGameSetting eVal,unsigned char ucV } ActionGameSettings(iPad,eVal); GameSettingsA[iPad]->bSettingsChanged=true; - } - break; + } + break; } } @@ -2286,9 +2348,19 @@ unsigned char CMinecraftApp::GetGameSettings(int iPad,eGameSetting eVal) case eGameSetting_SoundFXVolume: return GameSettingsA[iPad]->ucSoundFXVolume; break; + case eGameSetting_RenderDistance: + { + int val = (GameSettingsA[iPad]->uiBitmaskValues >> 16) & 0xFF; + if(val == 0) return val = 16; //brain + return val; + break; + } case eGameSetting_Gamma: return GameSettingsA[iPad]->ucGamma; break; + case eGameSetting_FOV: + return GameSettingsA[iPad]->ucFov; + break; case eGameSetting_Difficulty: return GameSettingsA[iPad]->usBitmaskValues&0x0003; break; @@ -2353,7 +2425,7 @@ unsigned char CMinecraftApp::GetGameSettings(int iPad,eGameSetting eVal) break; case eGameSetting_DisplayUpdateMessage: return (GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_DISPLAYUPDATEMSG)>>4; - break; + break; case eGameSetting_BedrockFog: return (GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_BEDROCKFOG)>>6; break; @@ -2470,7 +2542,7 @@ unsigned int CMinecraftApp::GetGameSettingsDebugMask(int iPad,bool bOverridePlay shared_ptr<Player> player = Minecraft::GetInstance()->localplayers[iPad]; - if(bOverridePlayer || player==NULL) + if(bOverridePlayer || player==nullptr) { return GameSettingsA[iPad]->uiDebugBitmask; } @@ -2644,7 +2716,7 @@ int CMinecraftApp::DisplaySavingMessage(void *pParam, C4JStorage::ESavingMessage void CMinecraftApp::SetActionConfirmed(LPVOID param) { - XuiActionParam *actionInfo = (XuiActionParam *)param; + XuiActionParam *actionInfo = static_cast<XuiActionParam *>(param); app.SetAction(actionInfo->iPad, actionInfo->action); } @@ -2685,13 +2757,13 @@ void CMinecraftApp::HandleXuiActions(void) param = m_eXuiActionParam[i]; 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() ) { @@ -2761,7 +2833,7 @@ void CMinecraftApp::HandleXuiActions(void) 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); @@ -2771,7 +2843,7 @@ void CMinecraftApp::HandleXuiActions(void) { // flag the render to capture the screenshot for the save - SetAction(i,eAppAction_AutosaveSaveGameCapturedThumbnail); + SetAction(i,eAppAction_AutosaveSaveGameCapturedThumbnail); } } @@ -2782,7 +2854,7 @@ void CMinecraftApp::HandleXuiActions(void) 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) + /*if(StorageManager.GetSaveName()==nullptr) { app.NavigateToScene(i,eUIScene_SaveWorld); } @@ -2800,7 +2872,7 @@ void CMinecraftApp::HandleXuiActions(void) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &UIScene_PauseMenu::SaveWorldThreadProc; - loadingParams->lpParam = (LPVOID)false; + loadingParams->lpParam = static_cast<LPVOID>(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; @@ -2834,7 +2906,7 @@ void CMinecraftApp::HandleXuiActions(void) break; case eAppAction_AutosaveSaveGameCapturedThumbnail: - { + { app.SetAutosaveTimerTime(); SetAction(i,eAppAction_Idle); @@ -2851,7 +2923,7 @@ void CMinecraftApp::HandleXuiActions(void) 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); + if(pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()] != nullptr) pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()]->getTutorial()->showTutorialPopup(false); //INT saveOrCheckpointId = 0; //bool validSave = StorageManager.GetSaveUniqueNumber(&saveOrCheckpointId); @@ -2861,7 +2933,7 @@ void CMinecraftApp::HandleXuiActions(void) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &UIScene_PauseMenu::SaveWorldThreadProc; - loadingParams->lpParam = (LPVOID)true; + loadingParams->lpParam = (LPVOID)(true); UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; @@ -2884,7 +2956,7 @@ void CMinecraftApp::HandleXuiActions(void) case eAppAction_ExitPlayer: // a secondary player has chosen to quit { - int iPlayerC=g_NetworkManager.GetPlayerCount(); + 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__) @@ -2905,7 +2977,7 @@ void CMinecraftApp::HandleXuiActions(void) // 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)); // } @@ -2927,7 +2999,7 @@ void CMinecraftApp::HandleXuiActions(void) // send the message for(int idx=0;idx<XUSER_MAX_COUNT;idx++) { - if((i!=idx) && (pMinecraft->localplayers[idx]!=NULL)) + if((i!=idx) && (pMinecraft->localplayers[idx]!=nullptr)) { XuiBroadcastMessage( CXuiSceneBase::GetPlayerBaseScene(idx), &xuiMsg ); } @@ -2944,9 +3016,9 @@ void CMinecraftApp::HandleXuiActions(void) 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); @@ -2961,9 +3033,9 @@ void CMinecraftApp::HandleXuiActions(void) 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); @@ -2978,7 +3050,7 @@ void CMinecraftApp::HandleXuiActions(void) #ifdef _DURANGO ProfileManager.RemoveGamepadFromGame(i); -#endif +#endif SetAction(i,eAppAction_Idle); } @@ -2991,7 +3063,7 @@ void CMinecraftApp::HandleXuiActions(void) StorageManager.ForceQueuedProfileWrites(i); #else ProfileManager.ForceQueuedProfileWrites(i); -#endif +#endif // if there are any tips showing, we need to close them pMinecraft->gui->clearMessages(i); @@ -3009,7 +3081,7 @@ void CMinecraftApp::HandleXuiActions(void) // send the message for(int idx=0;idx<XUSER_MAX_COUNT;idx++) { - if((i!=idx) && (pMinecraft->localplayers[idx]!=NULL)) + if((i!=idx) && (pMinecraft->localplayers[idx]!=nullptr)) { XuiBroadcastMessage( CXuiSceneBase::GetPlayerBaseScene(idx), &xuiMsg ); } @@ -3026,9 +3098,9 @@ void CMinecraftApp::HandleXuiActions(void) 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); @@ -3043,9 +3115,9 @@ void CMinecraftApp::HandleXuiActions(void) 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); @@ -3100,7 +3172,7 @@ void CMinecraftApp::HandleXuiActions(void) SetAction(i,eAppAction_Idle); // If we're already leaving don't exit - if (g_NetworkManager.IsLeavingGame()) + if (g_NetworkManager.IsLeavingGame()) { break; } @@ -3131,7 +3203,7 @@ void CMinecraftApp::HandleXuiActions(void) Minecraft::GetInstance()->forceStatsSave(j); } } - LeaderboardManager::Instance()->CloseSession(); + LeaderboardManager::Instance()->CloseSession(); #elif (defined _XBOX) ProfileManager.ForceQueuedProfileWrites(); #endif @@ -3151,7 +3223,7 @@ void CMinecraftApp::HandleXuiActions(void) #ifdef _DURANGO ProfileManager.RemoveGamepadFromGame(i); -#endif +#endif SetAction(i,eAppAction_Idle); return; } @@ -3173,9 +3245,9 @@ void CMinecraftApp::HandleXuiActions(void) 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); @@ -3194,7 +3266,7 @@ void CMinecraftApp::HandleXuiActions(void) { app.SetRichPresenceContext(i,CONTEXT_GAME_STATE_BLANK); if(g_NetworkManager.IsLocalGame()) - { + { ProfileManager.SetCurrentGameActivity(i,CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE,false); } else @@ -3230,24 +3302,24 @@ void CMinecraftApp::HandleXuiActions(void) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &UIScene_PauseMenu::ExitWorldThreadProc; - loadingParams->lpParam = param; + loadingParams->lpParam = param; 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->bRequiresUserAction = FALSE;//(param != nullptr) ? TRUE : FALSE; + completionData->bShowTips = (param != nullptr) ? FALSE : TRUE; 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); + ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_FullscreenProgress, loadingParams); } break; case eAppAction_ExitWorldTrial: - { + { SetAction(i,eAppAction_Idle); pMinecraft->gui->clearMessages(); @@ -3274,7 +3346,7 @@ void CMinecraftApp::HandleXuiActions(void) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &UIScene_PauseMenu::ExitWorldThreadProc; - loadingParams->lpParam = param; + loadingParams->lpParam = param; UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; @@ -3344,11 +3416,11 @@ void CMinecraftApp::HandleXuiActions(void) //app.NavigateToScene(i,eUIScene_FullscreenProgress, loadingParams, true); } - } + } break; case eAppAction_WaitForRespawnComplete: player = pMinecraft->localplayers[i]; - if(player != NULL && player->GetPlayerRespawned()) + if(player != nullptr && player->GetPlayerRespawned()) { SetAction(i,eAppAction_Idle); @@ -3373,7 +3445,7 @@ void CMinecraftApp::HandleXuiActions(void) break; case eAppAction_WaitForDimensionChangeComplete: player = pMinecraft->localplayers[i]; - if(player != NULL && player->connection && player->connection->isStarted()) + if(player != nullptr && player->connection && player->connection->isStarted()) { SetAction(i,eAppAction_Idle); ui.CloseUIScenes(i); @@ -3384,8 +3456,8 @@ void CMinecraftApp::HandleXuiActions(void) } break; case eAppAction_PrimaryPlayerSignedOut: - { - //SetAction(i,eAppAction_Idle); + { + //SetAction(i,eAppAction_Idle); // clear the autosavetimer that might be displayed ui.ShowAutosaveCountdownTimer(false); @@ -3403,10 +3475,10 @@ void CMinecraftApp::HandleXuiActions(void) // 4J-PB - the libs will display the Returned to Title screen // UINT 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 @@ -3454,7 +3526,7 @@ void CMinecraftApp::HandleXuiActions(void) if (!gameStarted) { - // 1. Exit + // 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. @@ -3478,7 +3550,7 @@ void CMinecraftApp::HandleXuiActions(void) } else { -#if defined __PS3__ || defined __ORBIS__ || defined __PSVITA__ +#if defined __PS3__ || defined __ORBIS__ || defined __PSVITA__ if(UIScene_LoadOrJoinMenu::isSaveTransferRunning()) { // the save transfer is still in progress, delay jumping back to the main menu until we've cleaned up @@ -3547,7 +3619,7 @@ void CMinecraftApp::HandleXuiActions(void) } LoadingInputParams *loadingParams = new LoadingInputParams(); - loadingParams->func = &CMinecraftApp::SignoutExitWorldThreadProc; + loadingParams->func = &CMinecraftApp::SignoutExitWorldThreadProc; UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; @@ -3585,7 +3657,7 @@ void CMinecraftApp::HandleXuiActions(void) break; case eAppAction_TrialOver: - { + { SetAction(i,eAppAction_Idle); UINT uiIDA[2]; uiIDA[0]=IDS_UNLOCK_TITLE; @@ -3597,7 +3669,7 @@ void CMinecraftApp::HandleXuiActions(void) // INVITES case eAppAction_DashboardTrialJoinFromInvite: - { + { TelemetryManager->RecordUpsellPresented(i, eSen_UpsellID_Full_Version_Of_Game, app.m_dwOfferID); SetAction(i,eAppAction_Idle); @@ -3609,7 +3681,7 @@ void CMinecraftApp::HandleXuiActions(void) } break; case eAppAction_ExitAndJoinFromInvite: - { + { UINT uiIDA[3]; SetAction(i,eAppAction_Idle); @@ -3618,7 +3690,7 @@ void CMinecraftApp::HandleXuiActions(void) #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; @@ -3628,7 +3700,7 @@ void CMinecraftApp::HandleXuiActions(void) 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; @@ -3648,7 +3720,7 @@ void CMinecraftApp::HandleXuiActions(void) ui.RequestErrorMessage(IDS_UNLOCK_TITLE, IDS_UNLOCK_ACCEPT_INVITE, uiIDA, 2, i,&CMinecraftApp::UnlockFullInviteReturned,this); } else - { + { uiIDA[0]=IDS_CONFIRM_CANCEL; uiIDA[1]=IDS_CONFIRM_OK; ui.RequestAlertMessage(IDS_EXIT_GAME, IDS_CONFIRM_LEAVE_VIA_INVITE, uiIDA, 2,i,&CMinecraftApp::ExitAndJoinFromInvite,this); @@ -3687,12 +3759,12 @@ void CMinecraftApp::HandleXuiActions(void) // 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; + DLCTexturePack *pDLCTexPack=nullptr; if(pTexPack->hasAudio()) { // get the dlc texture pack, and store it - pDLCTexPack=(DLCTexturePack *)pTexPack; + pDLCTexPack=static_cast<DLCTexturePack *>(pTexPack); } // change to the default texture pack @@ -3711,11 +3783,11 @@ void CMinecraftApp::HandleXuiActions(void) pMinecraft->soundEngine->playStreaming(L"", 0, 0, 0, 1, 1); #ifdef _XBOX - if(pDLCTexPack->m_pStreamedWaveBank!=NULL) + if(pDLCTexPack->m_pStreamedWaveBank!=nullptr) { pDLCTexPack->m_pStreamedWaveBank->Destroy(); } - if(pDLCTexPack->m_pSoundBank!=NULL) + if(pDLCTexPack->m_pSoundBank!=nullptr) { pDLCTexPack->m_pSoundBank->Destroy(); } @@ -3734,18 +3806,18 @@ void CMinecraftApp::HandleXuiActions(void) 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 ); - } + { + if (index == i || pMinecraft->localplayers[index] != nullptr) + { + 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 = static_cast<LPVOID>(&m_InviteData); UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; @@ -3768,7 +3840,7 @@ void CMinecraftApp::HandleXuiActions(void) g_NetworkManager.SetLocalGame(false); - JoinFromInviteData *inviteData = (JoinFromInviteData *)param; + JoinFromInviteData *inviteData = static_cast<JoinFromInviteData *>(param); // 4J-PB - clear any previous connection errors Minecraft::GetInstance()->clearConnectionFailed(); @@ -3783,7 +3855,7 @@ void CMinecraftApp::HandleXuiActions(void) if( index != inviteData->dwUserIndex && ProfileManager.IsSignedIn(index) ) { if( (m_InviteData.dwLocalUsersMask & g_NetworkManager.GetLocalPlayerMask( index ) ) == 0 ) - { + { ProfileManager.RemoveGamepadFromGame(index); } } @@ -3824,7 +3896,7 @@ void CMinecraftApp::HandleXuiActions(void) if( !GetChangingSessionType() && !g_NetworkManager.IsLocalGame() ) { - SetGameStarted(false); + SetGameStarted(false); SetChangingSessionType(true); SetReallyChangingSessionType(true); @@ -3843,7 +3915,7 @@ void CMinecraftApp::HandleXuiActions(void) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::ChangeSessionTypeThreadProc; - loadingParams->lpParam = NULL; + loadingParams->lpParam = nullptr; UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); #ifdef __PS3__ @@ -3865,7 +3937,7 @@ void CMinecraftApp::HandleXuiActions(void) } loadingParams->completionData = completionData; - ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_FullscreenProgress, loadingParams); + ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_FullscreenProgress, loadingParams); } } else if( g_NetworkManager.IsLeavingGame() ) @@ -3892,9 +3964,9 @@ void CMinecraftApp::HandleXuiActions(void) case eAppAction_SetDefaultOptions: SetAction(i,eAppAction_Idle); #if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__) - SetDefaultOptions((C4JStorage::PROFILESETTINGS *)param,i); + SetDefaultOptions((C4JStorage::PROFILESETTINGS *)param,i); #else - SetDefaultOptions((C_4JProfile::PROFILESETTINGS *)param,i); + SetDefaultOptions(static_cast<C_4JProfile::PROFILESETTINGS *>(param), i); #endif // if the profile data has been changed, then force a profile write @@ -3924,7 +3996,7 @@ void CMinecraftApp::HandleXuiActions(void) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CMinecraftApp::RemoteSaveThreadProc; - loadingParams->lpParam = NULL; + loadingParams->lpParam = nullptr; UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bRequiresUserAction=FALSE; @@ -3966,7 +4038,7 @@ void CMinecraftApp::HandleXuiActions(void) if(!app.GetGameStarted()) MinecraftServer::HaltServer(true); if( g_NetworkManager.IsInSession() ) - { + { app.SetAction(i,eAppAction_PrimaryPlayerSignedOutReturned); } else @@ -3983,12 +4055,12 @@ void CMinecraftApp::HandleXuiActions(void) { TelemetryManager->RecordBanLevel(i); -#if defined _XBOX - INetworkPlayer *pHost=g_NetworkManager.GetHostPlayer(); +#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(); + INetworkPlayer *pHost=g_NetworkManager.GetHostPlayer(); AddLevelToBannedLevelList(i,pHost->GetUID(),GetUniqueMapName(),true); #endif // primary player would exit the world, secondary would exit the player @@ -4004,7 +4076,7 @@ void CMinecraftApp::HandleXuiActions(void) } break; case eAppAction_LevelInBanLevelList: - { + { UINT uiIDA[2]; uiIDA[0]=IDS_BUTTON_REMOVE_FROM_BAN_LIST; uiIDA[1]=IDS_EXIT_GAME; @@ -4043,7 +4115,7 @@ void CMinecraftApp::HandleXuiActions(void) break; case eAppAction_ReloadTexturePack: - { + { SetAction(i,eAppAction_Idle); Minecraft *pMinecraft = Minecraft::GetInstance(); pMinecraft->textures->reloadAll(); @@ -4051,7 +4123,7 @@ void CMinecraftApp::HandleXuiActions(void) if(!pMinecraft->skins->isUsingDefaultSkin()) { - TexturePack *pTexturePack = pMinecraft->skins->getSelected(); + TexturePack *pTexturePack = pMinecraft->skins->getSelected(); DLCPack *pDLCPack=pTexturePack->getDLCPack(); @@ -4069,7 +4141,7 @@ void CMinecraftApp::HandleXuiActions(void) // 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); + Minecraft::GetInstance()->soundEngine->playStreaming(L"", 0, 0, 0, 1, 1); } } break; @@ -4078,7 +4150,7 @@ void CMinecraftApp::HandleXuiActions(void) { #ifndef _XBOX app.DebugPrintf( - "[Consoles_App] eAppAction_ReloadFont, ingame='%s'.\n", + "[Consoles_App] eAppAction_ReloadFont, ingame='%s'.\n", app.GetGameStarted() ? "Yes" : "No" ); SetAction(i,eAppAction_Idle); @@ -4129,7 +4201,7 @@ void CMinecraftApp::HandleXuiActions(void) eTMS = app.GetTMSAction(i); if(eTMS!=eTMSAction_Idle) - { + { switch(eTMS) { // TMS++ actions @@ -4154,7 +4226,7 @@ void CMinecraftApp::HandleXuiActions(void) #endif case eTMSAction_TMSPP_UserFileList: // retrieve the file list first -#if defined _XBOX +#if defined _XBOX SetTMSAction(i,eTMSAction_TMSPP_UserFileList_Waiting); app.TMSPP_RetrieveFileList(i,C4JStorage::eGlobalStorage_TitleUser,"\\",eTMSAction_TMSPP_XUIDSFile); #elif defined _XBOX_ONE @@ -4173,7 +4245,7 @@ void CMinecraftApp::HandleXuiActions(void) SetTMSAction(i,eTMSAction_TMSPP_DLCFile); #endif - break; + break; case eTMSAction_TMSPP_DLCFile: #if defined _XBOX || defined _XBOX_ONE SetTMSAction(i,eTMSAction_TMSPP_DLCFile_Waiting); @@ -4207,7 +4279,7 @@ void CMinecraftApp::HandleXuiActions(void) case eTMSAction_TMSPP_RetrieveFiles_HelpAndOptions: case eTMSAction_TMSPP_RetrieveFiles_DLCMain: // retrieve the file list first -#if defined _XBOX +#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); @@ -4219,11 +4291,11 @@ void CMinecraftApp::HandleXuiActions(void) #endif break; case eTMSAction_TMSPP_RetrieveUserFilelist_DLCFileOnly: -#if defined _XBOX +#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); + //StorageManager.TMSPP_DeleteFile(i,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"TP06.png",nullptr,nullptr, 0); SetTMSAction(i,eTMSAction_TMSPP_UserFileList_Waiting); app.TMSPP_RetrieveFileList(i,C4JStorage::eGlobalStorage_TitleUser,eTMSAction_TMSPP_DLCFileOnly); #else @@ -4312,7 +4384,7 @@ void CMinecraftApp::HandleXuiActions(void) int CMinecraftApp::BannedLevelDialogReturned(void *pParam,int iPad,const C4JStorage::EMessageResult result) { - CMinecraftApp* pApp = (CMinecraftApp*)pParam; + CMinecraftApp* pApp = static_cast<CMinecraftApp *>(pParam); //Minecraft *pMinecraft=Minecraft::GetInstance(); if(result==C4JStorage::EMessage_ResultAccept) @@ -4320,7 +4392,7 @@ int CMinecraftApp::BannedLevelDialogReturned(void *pParam,int iPad,const C4JStor #if defined _XBOX || defined _XBOX_ONE INetworkPlayer *pHost = g_NetworkManager.GetHostPlayer(); // unban the level - if (pHost != NULL) + if (pHost != nullptr) { #if defined _XBOX pApp->RemoveLevelFromBannedLevelList(iPad,((NetworkPlayerXbox *)pHost)->GetUID(),pApp->GetUniqueMapName()); @@ -4361,7 +4433,7 @@ void CMinecraftApp::loadMediaArchive() mediapath = L"Common\\Media\\MediaPSVita.arc"; #endif - if (!mediapath.empty()) + if (!mediapath.empty()) { m_mediaArchive = new ArchiveFile( File(mediapath) ); } @@ -4370,10 +4442,10 @@ void CMinecraftApp::loadMediaArchive() HANDLE hFile = CreateFile( path.c_str(), GENERIC_READ, FILE_SHARE_READ, - NULL, + nullptr, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, - NULL ); + nullptr ); if( hFile != INVALID_HANDLE_VALUE ) { @@ -4389,7 +4461,7 @@ void CMinecraftApp::loadMediaArchive() m_fBody, dwFileSize, &m_fSize, - NULL ); + nullptr ); assert( m_fSize == dwFileSize ); @@ -4401,7 +4473,7 @@ void CMinecraftApp::loadMediaArchive() { assert( false ); // AHHHHHHHHHHHH - m_mediaArchive = NULL; + m_mediaArchive = nullptr; } #endif } @@ -4410,7 +4482,7 @@ void CMinecraftApp::loadStringTable() { #ifndef _XBOX - if(m_stringTable!=NULL) + if(m_stringTable!=nullptr) { // we need to unload the current string table, this is a reload delete m_stringTable; @@ -4424,7 +4496,7 @@ void CMinecraftApp::loadStringTable() } else { - m_stringTable = NULL; + m_stringTable = nullptr; assert(false); // AHHHHHHHHH. } @@ -4437,12 +4509,12 @@ int CMinecraftApp::PrimaryPlayerSignedOutReturned(void *pParam,int iPad,const C4 //Minecraft *pMinecraft=Minecraft::GetInstance(); // if the player is null, we're in the menus - //if(Minecraft::GetInstance()->player!=NULL) + //if(Minecraft::GetInstance()->player!=nullptr) // 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 @@ -4458,10 +4530,10 @@ int CMinecraftApp::EthernetDisconnectReturned(void *pParam,int iPad,const C4JSto 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); - } + if (Minecraft::GetInstance()->player != nullptr) + { + 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 @@ -4490,7 +4562,7 @@ int CMinecraftApp::SignoutExitWorldThreadProc( void* lpParameter ) bool saveStats = false; if (pMinecraft->isClientSide() || g_NetworkManager.IsInSession() ) { - if(lpParameter != NULL ) + if(lpParameter != nullptr ) { switch( app.GetDisconnectReason() ) { @@ -4522,16 +4594,16 @@ int CMinecraftApp::SignoutExitWorldThreadProc( void* lpParameter ) } 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); + if( pMinecraft->levels[0] != nullptr ) pMinecraft->levels[0]->disconnect(false); + if( pMinecraft->levels[1] != nullptr ) 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] != nullptr ) pMinecraft->levels[0]->disconnect(); + if( pMinecraft->levels[1] != nullptr ) 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 @@ -4546,7 +4618,7 @@ int CMinecraftApp::SignoutExitWorldThreadProc( void* lpParameter ) } else { - if(lpParameter != NULL ) + if(lpParameter != nullptr ) { switch( app.GetDisconnectReason() ) { @@ -4583,11 +4655,11 @@ int CMinecraftApp::SignoutExitWorldThreadProc( void* lpParameter ) pMinecraft->progressRenderer->progressStartNoAbort( exitReasonStringId ); } } - pMinecraft->setLevel(NULL,exitReasonStringId,nullptr,saveStats,true); + pMinecraft->setLevel(nullptr,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(); // + app.m_gameRules.unloadCurrentGameRules(); // MinecraftServer::resetFlags(); @@ -4609,7 +4681,7 @@ int CMinecraftApp::UnlockFullInviteReturned(void *pParam,int iPad,C4JStorage::EM // 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) + if(pMinecraft->player==nullptr) { bNoPlayer=true; } @@ -4621,7 +4693,7 @@ int CMinecraftApp::UnlockFullInviteReturned(void *pParam,int iPad,C4JStorage::EM // 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); + ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,nullptr,&bContentRestricted,nullptr); if(bContentRestricted) { UINT uiIDA[1]; @@ -4666,7 +4738,7 @@ int CMinecraftApp::UnlockFullSaveReturned(void *pParam,int iPad,C4JStorage::EMes // 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); + ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,nullptr,&bContentRestricted,nullptr); if(bContentRestricted) { UINT uiIDA[1]; @@ -4690,7 +4762,7 @@ int CMinecraftApp::UnlockFullSaveReturned(void *pParam,int iPad,C4JStorage::EMes } #elif defined(__ORBIS__) else - { + { // Determine why they're not "signed in live" if (ProfileManager.isSignedInPSN(iPad)) { @@ -4702,7 +4774,7 @@ int CMinecraftApp::UnlockFullSaveReturned(void *pParam,int iPad,C4JStorage::EMes ui.RequestErrorMessage( IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, iPad); } else - { + { // Not signed in to PSN UINT uiIDA[1]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; @@ -4721,7 +4793,7 @@ int CMinecraftApp::UnlockFullSaveReturned(void *pParam,int iPad,C4JStorage::EMes int CMinecraftApp::UnlockFullExitReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - CMinecraftApp* pApp = (CMinecraftApp*)pParam; + CMinecraftApp* pApp = static_cast<CMinecraftApp *>(pParam); Minecraft *pMinecraft=Minecraft::GetInstance(); if(result==C4JStorage::EMessage_ResultAccept) @@ -4731,7 +4803,7 @@ int CMinecraftApp::UnlockFullExitReturned(void *pParam,int iPad,C4JStorage::EMes // 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); + ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,nullptr,&bContentRestricted,nullptr); if(bContentRestricted) { UINT uiIDA[1]; @@ -4759,7 +4831,7 @@ int CMinecraftApp::UnlockFullExitReturned(void *pParam,int iPad,C4JStorage::EMes } #elif defined(__ORBIS__) else - { + { // Determine why they're not "signed in live" if (ProfileManager.isSignedInPSN(iPad)) { @@ -4773,7 +4845,7 @@ int CMinecraftApp::UnlockFullExitReturned(void *pParam,int iPad,C4JStorage::EMes pApp->SetAction(pMinecraft->player->GetXboxPad(),eAppAction_ExitWorldTrial); } else - { + { // Not signed in to PSN UINT uiIDA[1]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; @@ -4793,7 +4865,7 @@ int CMinecraftApp::UnlockFullExitReturned(void *pParam,int iPad,C4JStorage::EMes int CMinecraftApp::TrialOverReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - CMinecraftApp* pApp = (CMinecraftApp*)pParam; + CMinecraftApp* pApp = static_cast<CMinecraftApp *>(pParam); Minecraft *pMinecraft=Minecraft::GetInstance(); if(result==C4JStorage::EMessage_ResultAccept) @@ -4804,7 +4876,7 @@ int CMinecraftApp::TrialOverReturned(void *pParam,int iPad,C4JStorage::EMessageR // 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); + ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,nullptr,&bContentRestricted,nullptr); if(bContentRestricted) { UINT uiIDA[1]; @@ -4851,14 +4923,14 @@ int CMinecraftApp::TrialOverReturned(void *pParam,int iPad,C4JStorage::EMessageR void CMinecraftApp::ProfileReadErrorCallback(void *pParam) { - CMinecraftApp *pApp=(CMinecraftApp *)pParam; + CMinecraftApp *pApp=static_cast<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 + // 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 @@ -4883,7 +4955,7 @@ void CMinecraftApp::SignInChangeCallback(LPVOID pParam,bool bPrimaryPlayerChange Minecraft::GetInstance()->user->name = convStringToWstring( ProfileManager.GetGamertag(ProfileManager.GetPrimaryPad())); #endif - CMinecraftApp *pApp=(CMinecraftApp *)pParam; + CMinecraftApp *pApp=static_cast<CMinecraftApp *>(pParam); // check if the primary player signed out int iPrimaryPlayer=ProfileManager.GetPrimaryPad(); @@ -4948,7 +5020,7 @@ void CMinecraftApp::SignInChangeCallback(LPVOID pParam,bool bPrimaryPlayerChange if(i == iPrimaryPlayer) continue; // 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) + if(hasGuestIdChanged && pApp->m_currentSigninInfo[i].dwGuestNumber != 0 && g_NetworkManager.GetLocalPlayerByUserIndex(i)!=nullptr) { pApp->DebugPrintf("Recommending removal of player at index %d because their guest id changed\n",i); pApp->SetAction(i, eAppAction_ExitPlayer); @@ -4964,15 +5036,15 @@ void CMinecraftApp::SignInChangeCallback(LPVOID pParam,bool bPrimaryPlayerChange bool bPlayerChanged=(uiChangedPlayers&(1<<i))==(1<<i); bool bPlayerSignedIn=((uiSignInData&(1<<i))!=0); - if( bPlayerChanged && (!bPlayerSignedIn || (bPlayerSignedIn && !ProfileManager.AreXUIDSEqual(pApp->m_currentSigninInfo[i].xuid, info.xuid) ) )) + 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-HG: If either the player is in the network manager or in the game, need to exit player // TODO: Do we need to check the network manager? - if (g_NetworkManager.GetLocalPlayerByUserIndex(i) != NULL || Minecraft::GetInstance()->localplayers[i] != NULL) + if (g_NetworkManager.GetLocalPlayerByUserIndex(i) != nullptr || Minecraft::GetInstance()->localplayers[i] != nullptr) { pApp->DebugPrintf("Player %d signed out\n", i); pApp->SetAction(i, eAppAction_ExitPlayer); @@ -4983,7 +5055,7 @@ void CMinecraftApp::SignInChangeCallback(LPVOID pParam,bool bPrimaryPlayerChange // 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(g_NetworkManager.GetLocalPlayerByUserIndex(i)!=nullptr) { if(ProfileManager.IsSignedInLive(i) == false) { @@ -5020,7 +5092,7 @@ void CMinecraftApp::SignInChangeCallback(LPVOID pParam,bool bPrimaryPlayerChange // 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 + if( i != iPrimaryPlayer && ( uiChangedPlayers & (1<<i) ) && ( uiSignInData & (1<<i) ) ) @@ -5058,7 +5130,7 @@ void CMinecraftApp::SignInChangeCallback(LPVOID pParam,bool bPrimaryPlayerChange void CMinecraftApp::NotificationsCallback(LPVOID pParam,DWORD dwNotification, unsigned int uiParam) { - CMinecraftApp* pClass = (CMinecraftApp*)pParam; + CMinecraftApp* pClass = static_cast<CMinecraftApp *>(pParam); // push these on to the notifications to be handled in qnet's dowork @@ -5080,7 +5152,7 @@ void CMinecraftApp::NotificationsCallback(LPVOID pParam,DWORD dwNotification, un for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { if(!InputManager.IsPadConnected(i) && - Minecraft::GetInstance()->localplayers[i] != NULL && + Minecraft::GetInstance()->localplayers[i] != nullptr && !ui.IsPauseMenuDisplayed(i) && !ui.IsSceneInStack(i, eUIScene_EndPoem) ) { ui.CloseUIScenes(i); @@ -5109,7 +5181,7 @@ void CMinecraftApp::NotificationsCallback(LPVOID pParam,DWORD dwNotification, un { DLCTexturePack *pDLCTexPack=(DLCTexturePack *)pTexPack; XCONTENTDEVICEID deviceID = pDLCTexPack->GetDLCDeviceID(); - if( XContentGetDeviceState( deviceID, NULL ) != ERROR_SUCCESS ) + if( XContentGetDeviceState( deviceID, nullptr ) != 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 @@ -5117,11 +5189,11 @@ void CMinecraftApp::NotificationsCallback(LPVOID pParam,DWORD dwNotification, un // 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) + if(pDLCTexPack->m_pStreamedWaveBank!=nullptr) { pDLCTexPack->m_pStreamedWaveBank->Destroy(); } - if(pDLCTexPack->m_pSoundBank!=NULL) + if(pDLCTexPack->m_pSoundBank!=nullptr) { pDLCTexPack->m_pSoundBank->Destroy(); } @@ -5140,7 +5212,7 @@ void CMinecraftApp::NotificationsCallback(LPVOID pParam,DWORD dwNotification, un #if defined __PS3__ || defined __PSVITA__ || defined __ORBIS__ int CMinecraftApp::MustSignInFullVersionPurchaseReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - if(result==C4JStorage::EMessage_ResultAccept) + if(result==C4JStorage::EMessage_ResultAccept) { #ifdef __PS3__ SQRNetworkManager_PS3::AttemptPSNSignIn(&CMinecraftApp::NowDisplayFullVersionPurchase, &app,true); @@ -5157,7 +5229,7 @@ int CMinecraftApp::MustSignInFullVersionPurchaseReturned(void *pParam,int iPad,C #if defined __PS3__ || defined __PSVITA__ || defined __ORBIS__ int CMinecraftApp::MustSignInFullVersionPurchaseReturnedExitTrial(void *pParam,int iPad,C4JStorage::EMessageResult result) { - if(result==C4JStorage::EMessage_ResultAccept) + if(result==C4JStorage::EMessage_ResultAccept) { #ifdef __PS3__ SQRNetworkManager_PS3::AttemptPSNSignIn(&CMinecraftApp::NowDisplayFullVersionPurchase, &app,true); @@ -5169,7 +5241,7 @@ int CMinecraftApp::MustSignInFullVersionPurchaseReturnedExitTrial(void *pParam,i } //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); + app.SetAction(iPad,eAppAction_ExitWorldTrial); return 0; } @@ -5212,9 +5284,9 @@ void CMinecraftApp::UpsellReturnedCallback(LPVOID pParam, eUpsellType type, eUps uiIDA[0]=IDS_CONFIRM_OK; ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, ProfileManager.GetPrimaryPad()); break; -#endif +#endif case eUpsellResponse_Declined: - default: + default: senResponse = eSen_UpsellOutcome_Declined; break; }; @@ -5230,7 +5302,7 @@ void CMinecraftApp::UpsellReturnedCallback(LPVOID pParam, eUpsellType type, eUps break; }; - // Always the primary pad that gets an upsell + // Always the primary pad that gets an upsell TelemetryManager->RecordUpsellResponded(ProfileManager.GetPrimaryPad(), eSen_UpsellID_Full_Version_Of_Game, app.m_dwOfferID, senResponse); } @@ -5247,7 +5319,7 @@ void CMinecraftApp::SetDebugSequence(const char *pchSeq) } int CMinecraftApp::DebugInputCallback(LPVOID pParam) { - CMinecraftApp* pClass = (CMinecraftApp*)pParam; + CMinecraftApp* pClass = static_cast<CMinecraftApp *>(pParam); //printf("sequence matched\n"); pClass->m_bDebugOptions=!pClass->m_bDebugOptions; @@ -5255,7 +5327,7 @@ int CMinecraftApp::DebugInputCallback(LPVOID pParam) { if(app.DebugSettingsOn()) { - app.ActionDebugMask(i); + app.ActionDebugMask(i); } else { @@ -5273,7 +5345,7 @@ int CMinecraftApp::GetLocalPlayerCount(void) Minecraft *pMinecraft = Minecraft::GetInstance(); for(int i=0;i<XUSER_MAX_COUNT;i++) { - if(pMinecraft != NULL && pMinecraft->localplayers[i] != NULL) + if(pMinecraft != nullptr && pMinecraft->localplayers[i] != nullptr) { iPlayerC++; } @@ -5347,7 +5419,7 @@ void CMinecraftApp::MountNextDLC(int iPad) 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); + app.DebugPrintf("Failed to mount DLC %d for pad %d\n",m_iTotalDLCInstalled,iPad); ++m_iTotalDLCInstalled; app.MountNextDLC(iPad); } @@ -5423,15 +5495,15 @@ int CMinecraftApp::DLCMountedCallback(LPVOID pParam,int iPad,DWORD dwErr,DWORD d DLCPack *pack = app.m_dlcManager.getPack( CONTENT_DATA_DISPLAY_NAME(ContentData) ); - if( pack != NULL && pack->IsCorrupt() ) + if( pack != nullptr && 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; + pack = nullptr; } - if(pack == NULL) + if(pack == nullptr) { app.DebugPrintf("Pack \"%ls\" is not installed, so adding it\n", CONTENT_DATA_DISPLAY_NAME(ContentData)); @@ -5475,16 +5547,16 @@ int CMinecraftApp::DLCMountedCallback(LPVOID pParam,int iPad,DWORD dwErr,DWORD d // void CMinecraftApp::InstallDefaultCape() // { // if(!m_bDefaultCapeInstallAttempted) -// { +// { // // we only attempt to install the cape once per launch of the game // m_bDefaultCapeInstallAttempted=true; -// +// // 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) -// { -// BYTE *pBuffer=NULL; +// { +// BYTE* pBuffer = nullptr; // DWORD dwSize=0; // // 4J-PB - out for now for DaveK so he doesn't get the birthday cape // #ifdef _CONTENT_PACKAGE @@ -5493,13 +5565,13 @@ int CMinecraftApp::DLCMountedCallback(LPVOID pParam,int iPad,DWORD dwErr,DWORD d // if(eTMSStatus==C4JStorage::ETMSStatus_Idle) // { // app.AddMemoryTextureFile(wTemp,pBuffer,dwSize); -// } +// } // #endif // } // } // } -void CMinecraftApp::HandleDLC(DLCPack *pack) +void CMinecraftApp::HandleDLC(DLCPack *pack) { DWORD dwFilesProcessed = 0; #ifndef _XBOX @@ -5513,7 +5585,7 @@ void CMinecraftApp::HandleDLC(DLCPack *pack) // 4J Stu - I don't know why we handle more than one file here any more, however this doesn't seem to work with the PS4 patches if(dlcFilenames.size() > 0) m_dlcManager.readDLCDataFile(dwFilesProcessed, dlcFilenames[0], pack); #else - for(int i=0; i<dlcFilenames.size();i++) + for(size_t i=0; i<dlcFilenames.size();i++) { m_dlcManager.readDLCDataFile(dwFilesProcessed, dlcFilenames[i], pack); } @@ -5552,9 +5624,9 @@ void CMinecraftApp::HandleDLC(DLCPack *pack) File texturePCKPath(wsTemp ); if(texturePCKPath.exists()) { - app.DebugPrintf("Found a replacement .pck\n"); + app.DebugPrintf("Found a replacement .pck\n"); m_dlcManager.readDLCDataFile(dwFilesProcessed, wsTemp,pack); - } + } else { m_dlcManager.readDLCDataFile(dwFilesProcessed, szFullFilename,pack); @@ -5564,7 +5636,7 @@ void CMinecraftApp::HandleDLC(DLCPack *pack) #endif } - } + } while( FindNextFile( hFind, &wfd ) ); // Close the find handle. @@ -5577,8 +5649,8 @@ void CMinecraftApp::HandleDLC(DLCPack *pack) // int CMinecraftApp::DLCReadCallback(LPVOID pParam,C4JStorage::DLC_FILE_DETAILS *pDLCData) // { -// -// +// +// // return 0; // } @@ -5587,20 +5659,20 @@ void CMinecraftApp::HandleDLC(DLCPack *pack) // Desc: Initializes the timer variables //------------------------------------------------------------------------------------- void CMinecraftApp::InitTime() -{ +{ // Get the frequency of the timer LARGE_INTEGER qwTicksPerSec; QueryPerformanceFrequency( &qwTicksPerSec ); - m_Time.fSecsPerTick = 1.0f / (float)qwTicksPerSec.QuadPart; + m_Time.fSecsPerTick = 1.0f / static_cast<float>(qwTicksPerSec.QuadPart); // Save the start time QueryPerformanceCounter( &m_Time.qwTime ); // Zero out the elapsed and total time m_Time.qwAppTime.QuadPart = 0; - m_Time.fAppTime = 0.0f; - m_Time.fElapsedTime = 0.0f; + m_Time.fAppTime = 0.0f; + m_Time.fElapsedTime = 0.0f; } //------------------------------------------------------------------------------------- @@ -5612,22 +5684,16 @@ void CMinecraftApp::UpdateTime() LARGE_INTEGER qwNewTime; LARGE_INTEGER qwDeltaTime; - QueryPerformanceCounter( &qwNewTime ); + QueryPerformanceCounter( &qwNewTime ); qwDeltaTime.QuadPart = qwNewTime.QuadPart - m_Time.qwTime.QuadPart; - m_Time.qwAppTime.QuadPart += qwDeltaTime.QuadPart; + m_Time.qwAppTime.QuadPart += qwDeltaTime.QuadPart; m_Time.qwTime.QuadPart = qwNewTime.QuadPart; - m_Time.fElapsedTime = m_Time.fSecsPerTick * ((FLOAT)(qwDeltaTime.QuadPart)); - m_Time.fAppTime = m_Time.fSecsPerTick * ((FLOAT)(m_Time.qwAppTime.QuadPart)); + m_Time.fElapsedTime = m_Time.fSecsPerTick * static_cast<FLOAT>(qwDeltaTime.QuadPart); + m_Time.fAppTime = m_Time.fSecsPerTick * static_cast<FLOAT>(m_Time.qwAppTime.QuadPart); } - - - - - - bool CMinecraftApp::isXuidNotch(PlayerUID xuid) { if(m_xuidNotch != INVALID_XUID && xuid != INVALID_XUID) @@ -5652,11 +5718,11 @@ bool CMinecraftApp::isXuidDeadmau5(PlayerUID xuid) return false; } -void CMinecraftApp::AddMemoryTextureFile(const wstring &wName,PBYTE pbData,DWORD dwBytes) -{ +void CMinecraftApp::AddMemoryTextureFile(const wstring &wName,PBYTE pbData,DWORD dwBytes) +{ EnterCriticalSection(&csMemFilesLock); // check it's not already in - PMEMDATA pData=NULL; + PMEMDATA pData=nullptr; auto it = m_MEM_Files.find(wName); if(it != m_MEM_Files.end()) { @@ -5667,8 +5733,8 @@ void CMinecraftApp::AddMemoryTextureFile(const wstring &wName,PBYTE pbData,DWORD if(pData->dwBytes == 0 && dwBytes != 0) { - // This should never be NULL if dwBytes is 0 - if(pData->pbData!=NULL) delete [] pData->pbData; + // This should never be nullptr if dwBytes is 0 + if(pData->pbData!=nullptr) delete [] pData->pbData; pData->pbData=pbData; pData->dwBytes=dwBytes; @@ -5729,7 +5795,7 @@ bool CMinecraftApp::DefaultCapeExists() EnterCriticalSection(&csMemFilesLock); auto it = m_MEM_Files.find(wTex); - if(it != m_MEM_Files.end()) val = true; + if(it != m_MEM_Files.end()) val = true; LeaveCriticalSection(&csMemFilesLock); return val; @@ -5741,7 +5807,7 @@ bool CMinecraftApp::IsFileInMemoryTextures(const wstring &wName) EnterCriticalSection(&csMemFilesLock); auto it = m_MEM_Files.find(wName); - if(it != m_MEM_Files.end()) val = true; + if(it != m_MEM_Files.end()) val = true; LeaveCriticalSection(&csMemFilesLock); return val; @@ -5760,14 +5826,14 @@ void CMinecraftApp::GetMemFileDetails(const wstring &wName,PBYTE *ppbData,DWORD LeaveCriticalSection(&csMemFilesLock); } -void CMinecraftApp::AddMemoryTPDFile(int iConfig,PBYTE pbData,DWORD dwBytes) -{ +void CMinecraftApp::AddMemoryTPDFile(int iConfig,PBYTE pbData,DWORD dwBytes) +{ EnterCriticalSection(&csMemTPDLock); // check it's not already in - PMEMDATA pData=NULL; + PMEMDATA pData=nullptr; auto it = m_MEM_TPD.find(iConfig); if(it == m_MEM_TPD.end()) - { + { pData = (PMEMDATA)new BYTE[sizeof(MEMDATA)]; ZeroMemory( pData, sizeof(MEMDATA) ); pData->pbData=pbData; @@ -5780,11 +5846,11 @@ void CMinecraftApp::AddMemoryTPDFile(int iConfig,PBYTE pbData,DWORD dwBytes) LeaveCriticalSection(&csMemTPDLock); } -void CMinecraftApp::RemoveMemoryTPDFile(int iConfig) -{ +void CMinecraftApp::RemoveMemoryTPDFile(int iConfig) +{ EnterCriticalSection(&csMemTPDLock); // check it's not already in - PMEMDATA pData=NULL; + PMEMDATA pData=nullptr; auto it = m_MEM_TPD.find(iConfig); if(it != m_MEM_TPD.end()) { @@ -5799,7 +5865,7 @@ void CMinecraftApp::RemoveMemoryTPDFile(int iConfig) #ifdef _XBOX int CMinecraftApp::GetTPConfigVal(WCHAR *pwchDataFile) { - DLC_INFO *pDLCInfo=NULL; + DLC_INFO *pDLCInfo=nullptr; // run through the DLC info to find the right texture pack/mash-up pack for(unsigned int i = 0; i < app.GetDLCInfoTexturesOffersCount(); ++i) { @@ -5817,7 +5883,7 @@ int CMinecraftApp::GetTPConfigVal(WCHAR *pwchDataFile) #elif defined _XBOX_ONE int CMinecraftApp::GetTPConfigVal(WCHAR *pwchDataFile) { - DLC_INFO *pDLCInfo=NULL; + DLC_INFO *pDLCInfo=nullptr; // run through the DLC info to find the right texture pack/mash-up pack for(unsigned int i = 0; i < app.GetDLCInfoTexturesOffersCount(); ++i) { @@ -5843,7 +5909,7 @@ bool CMinecraftApp::IsFileInTPD(int iConfig) EnterCriticalSection(&csMemTPDLock); auto it = m_MEM_TPD.find(iConfig); - if(it != m_MEM_TPD.end()) val = true; + if(it != m_MEM_TPD.end()) val = true; LeaveCriticalSection(&csMemTPDLock); return val; @@ -5869,18 +5935,18 @@ void CMinecraftApp::GetTPD(int iConfig,PBYTE *ppbData,DWORD *pdwBytes) // #ifndef _CONTENT_PACKAGE // // read the local file // File gtsFile( wsFile->c_str() ); -// -// __int64 fileSize = gtsFile.length(); -// +// +// int64_t 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); -// +// // } // #endif // return bRes; @@ -5913,7 +5979,7 @@ void CMinecraftApp::ProcessInvite(DWORD dwUserIndex, DWORD dwLocalUsersMask, con int CMinecraftApp::ExitAndJoinFromInvite(void *pParam,int iPad,C4JStorage::EMessageResult result) { - CMinecraftApp* pApp = (CMinecraftApp*)pParam; + CMinecraftApp* pApp = static_cast<CMinecraftApp *>(pParam); //Minecraft *pMinecraft=Minecraft::GetInstance(); // buttons are swapped on this menu @@ -5927,10 +5993,10 @@ int CMinecraftApp::ExitAndJoinFromInvite(void *pParam,int iPad,C4JStorage::EMess int CMinecraftApp::ExitAndJoinFromInviteSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - CMinecraftApp *pClass = (CMinecraftApp *)pParam; + CMinecraftApp *pClass = static_cast<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 || result==C4JStorage::EMessage_ResultThirdOption) { if( result==C4JStorage::EMessage_ResultDecline ) // Save { @@ -5942,7 +6008,7 @@ int CMinecraftApp::ExitAndJoinFromInviteSaveDialogReturned(void *pParam,int iPad DLCPack * pDLCPack=tPack->getDLCPack(); if(!pDLCPack->hasPurchasedFile( DLCManager::e_DLCType_Texture, L"" )) - { + { // upsell // get the dlc texture pack @@ -5962,7 +6028,7 @@ int CMinecraftApp::ExitAndJoinFromInviteSaveDialogReturned(void *pParam,int iPad // Give the player a warning about the trial version of the texture pack ui.RequestErrorMessage(IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, IDS_WARNING_DLC_TRIALTEXTUREPACK_TEXT, uiIDA, 2, iPad,&CMinecraftApp::WarningTrialTexturePackReturned,pClass); - return S_OK; + return S_OK; } } #ifndef _XBOX_ONE @@ -6018,7 +6084,7 @@ int CMinecraftApp::WarningTrialTexturePackReturned(void *pParam,int iPad,C4JStor { // 4J-PB - need to check this user can access the store bool bContentRestricted; - ProfileManager.GetChatAndContentRestrictions(iPad,true,NULL,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(iPad,true,nullptr,&bContentRestricted,nullptr); if(bContentRestricted) { UINT uiIDA[1]; @@ -6035,9 +6101,9 @@ int CMinecraftApp::WarningTrialTexturePackReturned(void *pParam,int iPad,C4JStor DLCPack *pDLCPack=pDLCTexPack->getDLCInfoParentPack();//tPack->getDLCPack(); const char *pchPackName=wstringtofilename(pDLCPack->getName()); app.DebugPrintf("Texture Pack - %s\n",pchPackName); - SONYDLC *pSONYDLCInfo=app.GetSONYDLCInfo((char *)pchPackName); + SONYDLC *pSONYDLCInfo=app.GetSONYDLCInfo((char *)pchPackName); - if(pSONYDLCInfo!=NULL) + if(pSONYDLCInfo!=nullptr) { char chName[42]; char chSkuID[SCE_NP_COMMERCE2_SKU_ID_LEN]; @@ -6056,27 +6122,27 @@ int CMinecraftApp::WarningTrialTexturePackReturned(void *pParam,int iPad,C4JStor #if defined __ORBIS__ || defined __PSVITA__ || defined __PS3__ if(app.CheckForEmptyStore(iPad)==false) #endif - { + { if(app.DLCAlreadyPurchased(chSkuID)) { app.DownloadAlreadyPurchased(chSkuID); } else { - app.Checkout(chSkuID); + app.Checkout(chSkuID); } } } } } } -#endif // +#endif // #ifdef _XBOX_ONE if(result==C4JStorage::EMessage_ResultAccept) { if(ProfileManager.IsSignedIn(iPad)) - { + { if (ProfileManager.IsSignedInLive(iPad)) { TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected(); @@ -6087,19 +6153,19 @@ int CMinecraftApp::WarningTrialTexturePackReturned(void *pParam,int iPad,C4JStor DLC_INFO *pDLCInfo=app.GetDLCInfoForProductName((WCHAR *)pDLCPack->getName().c_str()); - StorageManager.InstallOffer(1,(WCHAR *)pDLCInfo->wsProductId.c_str(),NULL,NULL); + StorageManager.InstallOffer(1,(WCHAR *)pDLCInfo->wsProductId.c_str(),nullptr,nullptr); - // the license change coming in when the offer has been installed will cause this scene to refresh + // the license change coming in when the offer has been installed will cause this scene to refresh } else - { + { // 4J-JEV: Fix for XB1: #165863 - XR-074: Compliance: With no active network connection user is unable to convert from Trial to Full texture pack and is not messaged why. UINT uiIDA[1] = { IDS_CONFIRM_OK }; - ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, iPad); + ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, iPad); } } } - + #endif #ifdef _XBOX @@ -6116,11 +6182,11 @@ int CMinecraftApp::WarningTrialTexturePackReturned(void *pParam,int iPad,C4JStor 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); + StorageManager.InstallOffer(1,ullIndexA,nullptr,nullptr); } } else @@ -6136,7 +6202,7 @@ int CMinecraftApp::ExitAndJoinFromInviteAndSaveReturned(void *pParam,int iPad,C4 //CMinecraftApp* pClass = (CMinecraftApp*)pParam; // results switched for this dialog - if(result==C4JStorage::EMessage_ResultDecline) + if(result==C4JStorage::EMessage_ResultDecline) { INT saveOrCheckpointId = 0; @@ -6148,7 +6214,7 @@ int CMinecraftApp::ExitAndJoinFromInviteAndSaveReturned(void *pParam,int iPad,C4 DLCPack * pDLCPack=tPack->getDLCPack(); if(!pDLCPack->hasPurchasedFile( DLCManager::e_DLCType_Texture, L"" )) - { + { // upsell // get the dlc texture pack @@ -6166,9 +6232,9 @@ int CMinecraftApp::ExitAndJoinFromInviteAndSaveReturned(void *pParam,int iPad,C4 uiIDA[1]=IDS_CONFIRM_CANCEL; // Give the player a warning about the trial version of the texture pack - ui.RequestErrorMessage(IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, IDS_WARNING_DLC_TRIALTEXTUREPACK_TEXT, uiIDA, 2, iPad,&CMinecraftApp::WarningTrialTexturePackReturned,NULL); + ui.RequestErrorMessage(IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, IDS_WARNING_DLC_TRIALTEXTUREPACK_TEXT, uiIDA, 2, iPad,&CMinecraftApp::WarningTrialTexturePackReturned,nullptr); - return S_OK; + return S_OK; } } //bool validSave = StorageManager.GetSaveUniqueNumber(&saveOrCheckpointId); @@ -6183,7 +6249,7 @@ int CMinecraftApp::ExitAndJoinFromInviteAndSaveReturned(void *pParam,int iPad,C4 int CMinecraftApp::ExitAndJoinFromInviteDeclineSaveReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { // results switched for this dialog - if(result==C4JStorage::EMessage_ResultDecline) + if(result==C4JStorage::EMessage_ResultDecline) { #if defined(_XBOX_ONE) || defined(__ORBIS__) StorageManager.SetSaveDisabled(false); @@ -6372,7 +6438,7 @@ UINT CMinecraftApp::GetNextTip() } else { - if(bShowSkinDLCTip && ProfileManager.IsFullVersion()) + if(bShowSkinDLCTip && ProfileManager.IsFullVersion()) { bShowSkinDLCTip=false; if( app.DLCInstallProcessCompleted() ) @@ -6484,7 +6550,7 @@ wstring CMinecraftApp::FormatHTMLString(int iPad, const wstring &desc, int shado 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_ACTION_MENU_PAGEDOWN*}", GetActionReplacement(iPad,ACTION_MENU_PAGEDOWN ) ); - text = replaceAll(text, L"{*CONTROLLER_ACTION_DISMOUNT*}", GetActionReplacement(iPad,MINECRAFT_ACTION_SNEAK_TOGGLE ) ); + text = replaceAll(text, L"{*CONTROLLER_ACTION_DISMOUNT*}", GetActionReplacement(iPad,MINECRAFT_ACTION_SNEAK_TOGGLE ) ); 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) ); @@ -6499,7 +6565,7 @@ wstring CMinecraftApp::FormatHTMLString(int iPad, const wstring &desc, int shado 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_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 ) ); @@ -6515,13 +6581,13 @@ wstring CMinecraftApp::FormatHTMLString(int iPad, const wstring &desc, int shado 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 + // Fix for #8903 - UI: Localization: KOR/JPN/CHT: Button Icons are rendered with padding space, which looks no good DWORD dwLanguage = XGetLanguage( ); switch(dwLanguage) { - case XC_LANGUAGE_KOREAN: + case XC_LANGUAGE_KOREAN: case XC_LANGUAGE_JAPANESE: - case XC_LANGUAGE_TCHINESE: + case XC_LANGUAGE_TCHINESE: text = replaceAll(text, L" ", L"" ); break; } @@ -6664,7 +6730,7 @@ wstring CMinecraftApp::GetVKReplacement(unsigned int uiVKey) case VK_PAD_LTHUMB_UPLEFT : case VK_PAD_LTHUMB_UPRIGHT : case VK_PAD_LTHUMB_DOWNRIGHT: - case VK_PAD_LTHUMB_DOWNLEFT : + case VK_PAD_LTHUMB_DOWNLEFT : return app.GetString( IDS_CONTROLLER_LEFT_STICK ); case VK_PAD_RTHUMB_UP : case VK_PAD_RTHUMB_DOWN : @@ -6673,12 +6739,12 @@ wstring CMinecraftApp::GetVKReplacement(unsigned int uiVKey) case VK_PAD_RTHUMB_UPLEFT : case VK_PAD_RTHUMB_UPRIGHT : case VK_PAD_RTHUMB_DOWNRIGHT: - case VK_PAD_RTHUMB_DOWNLEFT : + case VK_PAD_RTHUMB_DOWNLEFT : return app.GetString( IDS_CONTROLLER_RIGHT_STICK ); default: break; } - return NULL; + return nullptr; #else wstring replacement = L""; switch(uiVKey) @@ -6777,7 +6843,7 @@ wstring CMinecraftApp::GetIconReplacement(unsigned int uiIcon) default: break; } - return NULL; + return nullptr; #else wchar_t string[128]; @@ -6832,11 +6898,11 @@ HRESULT CMinecraftApp::RegisterMojangData(WCHAR *pXuidName, PlayerUID xuid, WCHA { HRESULT hr=S_OK; eXUID eTempXuid=eXUID_Undefined; - MOJANG_DATA *pMojangData=NULL; + MOJANG_DATA *pMojangData=nullptr; // ignore the names if we don't recognize them - if(pXuidName!=NULL) - { + if (pXuidName != nullptr) + { if( wcscmp( pXuidName, L"XUID_NOTCH" ) == 0 ) { eTempXuid = eXUID_Notch; // might be needed for the apple at some point @@ -6875,7 +6941,7 @@ HRESULT CMinecraftApp::RegisterConfigValues(WCHAR *pType, int iValue) HRESULT hr=S_OK; // #ifdef _XBOX - // if(pType!=NULL) + // if(pType!=nullptr) // { // if(wcscmp(pType,L"XboxOneTransfer")==0) // { @@ -6892,7 +6958,7 @@ HRESULT CMinecraftApp::RegisterConfigValues(WCHAR *pType, int iValue) // { // app.m_uiTransferSlotC=iValue; // } - // + // // } // #endif @@ -6901,7 +6967,7 @@ HRESULT CMinecraftApp::RegisterConfigValues(WCHAR *pType, int iValue) } #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 CMinecraftApp::RegisterDLCData(WCHAR *pType, WCHAR *pBannerName, int iGender, uint64_t ullOfferID_Full, uint64_t ullOfferID_Trial, WCHAR *pFirstSkin, unsigned int uiSortIndex, int iConfig, WCHAR *pDataFile) { HRESULT hr=S_OK; DLC_INFO *pDLCData=new DLC_INFO; @@ -6916,17 +6982,17 @@ HRESULT CMinecraftApp::RegisterDLCData(WCHAR *pType, WCHAR *pBannerName, int iGe #ifndef __ORBIS__ // 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); } #endif - if(pType!=NULL) + if(pType!=nullptr) { if(wcscmp(pType,L"Skin")==0) { @@ -7006,12 +7072,12 @@ HRESULT CMinecraftApp::RegisterDLCData(eDLCContentType eType, WCHAR *pwchBannerN // 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; } @@ -7053,7 +7119,7 @@ HRESULT CMinecraftApp::RegisterDLCData(char *pchDLCName, unsigned int uiSortInde pDLCData->iConfig = app.GetiConfigFromName(pchDLCName); pDLCData->uiSortIndex=uiSortIndex; - pDLCData->eDLCType = app.GetDLCTypeFromName(pchDLCName); + pDLCData->eDLCType = app.GetDLCTypeFromName(pchDLCName); strcpy(pDLCData->chImageURL,pchImageURL); //bool bIsTrialDLC = app.GetTrialFromName(pchDLCName); @@ -7111,7 +7177,7 @@ bool CMinecraftApp::GetDLCNameForPackID(const int iPackID,char **ppchKeyID) auto it = DLCTextures_PackID.find(iPackID); if( it == DLCTextures_PackID.end() ) { - *ppchKeyID=NULL; + *ppchKeyID=nullptr; return false; } else @@ -7125,27 +7191,27 @@ DLC_INFO *CMinecraftApp::GetDLCInfo(char *pchDLCName) string tempString=pchDLCName; if(DLCInfo.size()>0) - { + { auto it = DLCInfo.find(tempString); if( it == DLCInfo.end() ) { // nothing for this - return NULL; + return nullptr; } else { return it->second; } } - else return NULL; + else return nullptr; } DLC_INFO *CMinecraftApp::GetDLCInfoFromTPackID(int iTPID) { unordered_map<string, DLC_INFO *>::iterator it= DLCInfo.begin(); - for(int i=0;i<DLCInfo.size();i++) + for(size_t i=0;i<DLCInfo.size();i++) { if(((DLC_INFO *)it->second)->iConfig==iTPID) { @@ -7153,7 +7219,7 @@ DLC_INFO *CMinecraftApp::GetDLCInfoFromTPackID(int iTPID) } ++it; } - return NULL; + return nullptr; } DLC_INFO *CMinecraftApp::GetDLCInfo(int iIndex) @@ -7198,7 +7264,7 @@ bool CMinecraftApp::GetDLCFullOfferIDForPackID(const int iPackID,wstring &Produc { auto it = DLCTextures_PackID.find(iPackID); if( it == DLCTextures_PackID.end() ) - { + { return false; } else @@ -7209,12 +7275,12 @@ bool CMinecraftApp::GetDLCFullOfferIDForPackID(const int iPackID,wstring &Produc } // DLC_INFO *CMinecraftApp::GetDLCInfoForTrialOfferID(wstring &ProductId) // { -// return NULL; +// return nullptr; // } DLC_INFO *CMinecraftApp::GetDLCInfoTrialOffer(int iIndex) { - return NULL; + return nullptr; } DLC_INFO *CMinecraftApp::GetDLCInfoFullOffer(int iIndex) { @@ -7268,22 +7334,22 @@ bool CMinecraftApp::GetDLCFullOfferIDForPackID(const int iPackID,ULONGLONG *pull } DLC_INFO *CMinecraftApp::GetDLCInfoForTrialOfferID(ULONGLONG ullOfferID_Trial) { - //DLC_INFO *pDLCInfo=NULL; + //DLC_INFO *pDLCInfo=nullptr; if(DLCInfo_Trial.size()>0) - { + { auto it = DLCInfo_Trial.find(ullOfferID_Trial); if( it == DLCInfo_Trial.end() ) { // nothing for this - return NULL; + return nullptr; } else { return it->second; } } - else return NULL; + else return nullptr; } DLC_INFO *CMinecraftApp::GetDLCInfoTrialOffer(int iIndex) @@ -7327,27 +7393,27 @@ DLC_INFO *CMinecraftApp::GetDLCInfoForFullOfferID(WCHAR *pwchProductID) { wstring wsTemp = pwchProductID; if(DLCInfo_Full.size()>0) - { + { auto it = DLCInfo_Full.find(wsTemp); if( it == DLCInfo_Full.end() ) { // nothing for this - return NULL; + return nullptr; } else { return it->second; } } - else return NULL; + else return nullptr; } DLC_INFO *CMinecraftApp::GetDLCInfoForProductName(WCHAR *pwchProductName) { unordered_map<wstring, DLC_INFO *>::iterator it= DLCInfo_Full.begin(); wstring wsProductName=pwchProductName; - for(int i=0;i<DLCInfo_Full.size();i++) + for(size_t i=0;i<DLCInfo_Full.size();i++) { DLC_INFO *pDLCInfo=(DLC_INFO *)it->second; if(wsProductName==pDLCInfo->wsDisplayName) @@ -7357,7 +7423,7 @@ DLC_INFO *CMinecraftApp::GetDLCInfoForProductName(WCHAR *pwchProductName) ++it; } - return NULL; + return nullptr; } #elif defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__) @@ -7367,20 +7433,20 @@ DLC_INFO *CMinecraftApp::GetDLCInfoForFullOfferID(ULONGLONG ullOfferID_Full) { if(DLCInfo_Full.size()>0) - { + { auto it = DLCInfo_Full.find(ullOfferID_Full); if( it == DLCInfo_Full.end() ) { // nothing for this - return NULL; + return nullptr; } else { return it->second; } } - else return NULL; + else return nullptr; } #endif @@ -7471,7 +7537,7 @@ void CMinecraftApp::ExitGameFromRemoteSave( LPVOID lpParameter ) uiIDA[0]=IDS_CONFIRM_CANCEL; uiIDA[1]=IDS_CONFIRM_OK; - ui.RequestAlertMessage(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2, primaryPad,&CMinecraftApp::ExitGameFromRemoteSaveDialogReturned,NULL); + ui.RequestAlertMessage(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2, primaryPad,&CMinecraftApp::ExitGameFromRemoteSaveDialogReturned,nullptr); } int CMinecraftApp::ExitGameFromRemoteSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) @@ -7479,17 +7545,17 @@ int CMinecraftApp::ExitGameFromRemoteSaveDialogReturned(void *pParam,int iPad,C4 //CScene_Pause* pClass = (CScene_Pause*)pParam; // results switched for this dialog - if(result==C4JStorage::EMessage_ResultDecline) + if(result==C4JStorage::EMessage_ResultDecline) { app.SetAction(iPad,eAppAction_ExitWorld); } - else + else { #ifndef _XBOX // Inform fullscreen progress scene that it's not being cancelled after all - UIScene_FullscreenProgress *pScene = (UIScene_FullscreenProgress *)ui.FindScene(eUIScene_FullscreenProgress); + UIScene_FullscreenProgress *pScene = static_cast<UIScene_FullscreenProgress *>(ui.FindScene(eUIScene_FullscreenProgress)); #ifdef __PS3__ - if(pScene!=NULL) + if(pScene!=nullptr) #else if (pScene != nullptr) #endif @@ -7505,7 +7571,7 @@ int CMinecraftApp::ExitGameFromRemoteSaveDialogReturned(void *pParam,int iPad,C4 void CMinecraftApp::SetSpecialTutorialCompletionFlag(int iPad, int index) { - if(index >= 0 && index < 32 && GameSettingsA[iPad] != NULL) + if(index >= 0 && index < 32 && GameSettingsA[iPad] != nullptr) { GameSettingsA[iPad]->uiSpecialTutorialBitmask |= (1<<index); } @@ -7534,7 +7600,7 @@ void CMinecraftApp::InvalidateBannedList(int iPad) if(BannedListA[iPad].pBannedList) { delete [] BannedListA[iPad].pBannedList; - BannedListA[iPad].pBannedList=NULL; + BannedListA[iPad].pBannedList=nullptr; } } } @@ -7563,10 +7629,10 @@ void CMinecraftApp::AddLevelToBannedLevelList(int iPad, PlayerUID xuid, char *ps strcpy(pBannedListData->pszLevelName,pszLevelName); m_vBannedListA[iPad]->push_back(pBannedListData); - if(bWriteToTMS) - { - DWORD dwDataBytes=(DWORD)(sizeof(BANNEDLISTDATA)*m_vBannedListA[iPad]->size()); - PBANNEDLISTDATA pBannedList = (BANNEDLISTDATA *)(new CHAR [dwDataBytes]); + if (bWriteToTMS) + { + DWORD dwDataBytes = static_cast<DWORD>(sizeof(BANNEDLISTDATA)* m_vBannedListA[iPad]->size()); + PBANNEDLISTDATA pBannedList = reinterpret_cast<BANNEDLISTDATA*>(new CHAR [dwDataBytes]); int iCount=0; for (PBANNEDLISTDATA pData : *m_vBannedListA[iPad] ) { @@ -7577,9 +7643,9 @@ void CMinecraftApp::AddLevelToBannedLevelList(int iPad, PlayerUID xuid, char *ps //bool bRes=StorageManager.WriteTMSFile(iPad,C4JStorage::eGlobalStorage_TitleUser,L"BannedList",(PBYTE)pBannedList, dwDataBytes); #ifdef _XBOX - StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,C4JStorage::TMS_UGCTYPE_NONE,"BannedList",(PCHAR) pBannedList, dwDataBytes,NULL,NULL, 0); + StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,C4JStorage::TMS_UGCTYPE_NONE,"BannedList",(PCHAR) pBannedList, dwDataBytes,nullptr,nullptr, 0); #elif defined _XBOX_ONE - StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"BannedList",(PBYTE) pBannedList, dwDataBytes,NULL,NULL, 0); + StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"BannedList",(PBYTE) pBannedList, dwDataBytes,nullptr,nullptr, 0); #endif } // update telemetry too @@ -7592,7 +7658,7 @@ bool CMinecraftApp::IsInBannedLevelList(int iPad, PlayerUID xuid, char *pszLevel #ifdef _XBOX_ONE PlayerUID bannedPlayerUID = pData->wchPlayerUID; if(IsEqualXUID (bannedPlayerUID,xuid) && (strcmp(pData->pszLevelName,pszLevelName)==0)) -#else +#else if(IsEqualXUID (pData->xuid,xuid) && (strcmp(pData->pszLevelName,pszLevelName)==0)) #endif { @@ -7613,7 +7679,7 @@ void CMinecraftApp::RemoveLevelFromBannedLevelList(int iPad, PlayerUID xuid, cha { PBANNEDLISTDATA pBannedListData = *it; - if(pBannedListData!=NULL) + if(pBannedListData!=nullptr) { #ifdef _XBOX_ONE PlayerUID bannedPlayerUID = pBannedListData->wchPlayerUID; @@ -7638,22 +7704,22 @@ void CMinecraftApp::RemoveLevelFromBannedLevelList(int iPad, PlayerUID xuid, cha } } - DWORD dwDataBytes=(DWORD)(sizeof(BANNEDLISTDATA)*m_vBannedListA[iPad]->size()); + DWORD dwDataBytes=static_cast<DWORD>(sizeof(BANNEDLISTDATA) * m_vBannedListA[iPad]->size()); if(dwDataBytes==0) { // wipe the file #ifdef _XBOX 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",nullptr,nullptr, 0); #endif } else { PBANNEDLISTDATA pBannedList = (BANNEDLISTDATA *)(new BYTE [dwDataBytes]); - int iSize=(int)m_vBannedListA[iPad]->size(); - for(int i=0;i<iSize;i++) + size_t iSize=m_vBannedListA[iPad]->size(); + for(size_t i=0;i<iSize;i++) { PBANNEDLISTDATA pBannedListData =m_vBannedListA[iPad]->at(i); @@ -7662,7 +7728,7 @@ void CMinecraftApp::RemoveLevelFromBannedLevelList(int iPad, PlayerUID xuid, cha #ifdef _XBOX StorageManager.WriteTMSFile(iPad,C4JStorage::eGlobalStorage_TitleUser,L"BannedList",(PBYTE)pBannedList, dwDataBytes); #elif defined _XBOX_ONE - StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"BannedList",(PBYTE) pBannedList, dwDataBytes,NULL,NULL, 0); + StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"BannedList",(PBYTE) pBannedList, dwDataBytes,nullptr,nullptr, 0); #endif delete [] pBannedList; } @@ -7693,7 +7759,7 @@ bool CMinecraftApp::AlreadySeenCreditText(const wstring &wstemp) wstring temp=m_vCreditText.at(i); // if they are the same, break out of the case - if(temp.compare(wstemp)==0) + if(temp.compare(wstemp)==0) { return true; } @@ -7706,7 +7772,7 @@ bool CMinecraftApp::AlreadySeenCreditText(const wstring &wstemp) unsigned int CMinecraftApp::GetDLCCreditsCount() { - return (unsigned int)vDLCCredits.size(); + return static_cast<unsigned int>(vDLCCredits.size()); } SCreditTextItemDef * CMinecraftApp::GetDLCCredits(int iIndex) @@ -8081,7 +8147,7 @@ unsigned int CMinecraftApp::GetGameHostOption(unsigned int uiHostSettings, eGame break; case eGameHostOption_FireSpreads: return (uiHostSettings&GAME_HOST_OPTION_BITMASK_FIRESPREADS); - break; + break; case eGameHostOption_CheatsEnabled: return (uiHostSettings&(GAME_HOST_OPTION_BITMASK_HOSTFLY|GAME_HOST_OPTION_BITMASK_HOSTHUNGER|GAME_HOST_OPTION_BITMASK_HOSTINVISIBLE)); break; @@ -8099,7 +8165,7 @@ unsigned int CMinecraftApp::GetGameHostOption(unsigned int uiHostSettings, eGame break; case eGameHostOption_DisableSaving: return (uiHostSettings&GAME_HOST_OPTION_BITMASK_DISABLESAVE); - break; + break; case eGameHostOption_WasntSaveOwner: return (uiHostSettings&GAME_HOST_OPTION_BITMASK_NOTOWNER); case eGameHostOption_WorldSize: @@ -8118,7 +8184,7 @@ unsigned int CMinecraftApp::GetGameHostOption(unsigned int uiHostSettings, eGame return !(uiHostSettings&GAME_HOST_OPTION_BITMASK_NATURALREGEN); case eGameHostOption_DoDaylightCycle: return !(uiHostSettings&GAME_HOST_OPTION_BITMASK_DODAYLIGHTCYCLE); - break; + break; } return false; @@ -8126,7 +8192,7 @@ unsigned int CMinecraftApp::GetGameHostOption(unsigned int uiHostSettings, eGame bool CMinecraftApp::CanRecordStatsAndAchievements() { - bool isTutorial = Minecraft::GetInstance() != NULL && Minecraft::GetInstance()->isTutorial(); + bool isTutorial = Minecraft::GetInstance() != nullptr && Minecraft::GetInstance()->isTutorial(); // 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) || @@ -8178,7 +8244,7 @@ unsigned int CMinecraftApp::FromBigEndian(unsigned int uiValue) // Keep it in big endian return uiValue; #else - unsigned int uiReturn = ( ( uiValue >> 24 ) & 0x000000ff ) | + unsigned int uiReturn = ( ( uiValue >> 24 ) & 0x000000ff ) | ( ( uiValue >> 8 ) & 0x0000ff00 ) | ( ( uiValue << 8 ) & 0x00ff0000 ) | ( ( uiValue << 24 ) & 0xff000000 ); @@ -8204,7 +8270,7 @@ void CMinecraftApp::GetImageTextData(PBYTE pbImageData, DWORD dwImageBytes,unsig uiCount+=8; while(uiCount<dwImageBytes) - { + { uiChunkLen=*(unsigned int *)&ucPtr[uiCount]; uiChunkLen=FromBigEndian(uiChunkLen); uiCount+=sizeof(int); @@ -8228,7 +8294,7 @@ void CMinecraftApp::GetImageTextData(PBYTE pbImageData, DWORD dwImageBytes,unsig pszKeyword++; if(strcmp(szKeyword,"4J_SEED")==0) { - // read the seed value + // read the seed value unsigned int uiValueC=0; while(*pszKeyword!=0 && (pszKeyword < ucPtr + uiCount + uiChunkLen) ) { @@ -8240,7 +8306,7 @@ void CMinecraftApp::GetImageTextData(PBYTE pbImageData, DWORD dwImageBytes,unsig else if(strcmp(szKeyword,"4J_HOSTOPTIONS")==0) { bHostOptionsRead = true; - // read the host options value + // read the host options value unsigned int uiValueC=0; unsigned char pszHostOptions[9]; // Hex representation of unsigned int ZeroMemory(&pszHostOptions,9); @@ -8257,7 +8323,7 @@ void CMinecraftApp::GetImageTextData(PBYTE pbImageData, DWORD dwImageBytes,unsig } else if(strcmp(szKeyword,"4J_TEXTUREPACK")==0) { - // read the texture pack value + // read the texture pack value unsigned int uiValueC=0; unsigned char pszTexturePack[9]; // Hex representation of unsigned int ZeroMemory(&pszTexturePack,9); @@ -8282,7 +8348,7 @@ void CMinecraftApp::GetImageTextData(PBYTE pbImageData, DWORD dwImageBytes,unsig return; } -unsigned int CMinecraftApp::CreateImageTextData(PBYTE bTextMetadata, __int64 seed, bool hasSeed, unsigned int uiHostOptions, unsigned int uiTexturePackId) +unsigned int CMinecraftApp::CreateImageTextData(PBYTE bTextMetadata, int64_t seed, bool hasSeed, unsigned int uiHostOptions, unsigned int uiTexturePackId) { int iTextMetadataBytes = 0; if(hasSeed) @@ -8349,7 +8415,7 @@ bool CMinecraftApp::GetTerrainFeaturePosition(_eTerrainFeatureType eType,int *pX *pX=pFeatureData->x; *pZ=pFeatureData->z; return true; - } + } } return false; @@ -8494,7 +8560,7 @@ unsigned int CMinecraftApp::AddDLCRequest(eDLCMarketplaceType eType, bool bPromo { // promote if(bPromote) - { + { m_DLCDownloadQueue.erase(m_DLCDownloadQueue.begin()+iPosition); m_DLCDownloadQueue.insert(m_DLCDownloadQueue.begin(),pCurrent); } @@ -8506,10 +8572,10 @@ unsigned int CMinecraftApp::AddDLCRequest(eDLCMarketplaceType eType, bool bPromo } DLCRequest *pDLCreq = new DLCRequest; - pDLCreq->dwType=m_dwContentTypeA[eType]; + 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); @@ -8541,7 +8607,7 @@ unsigned int CMinecraftApp::AddTMSPPFileTypeRequest(eDLCContentType eType, bool { // promote if(bPromote) - { + { m_TMSPPDownloadQueue.erase(m_TMSPPDownloadQueue.begin()+iPosition); m_TMSPPDownloadQueue.insert(m_TMSPPDownloadQueue.begin(),pCurrent); bPromoted=true; @@ -8575,17 +8641,17 @@ unsigned int CMinecraftApp::AddTMSPPFileTypeRequest(eDLCContentType eType, bool { // 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); //if(iIndex!=-1) - { + { bool bPresent = app.IsFileInTPD(pDLC->iConfig); if(!bPresent) - { + { // this may already be present in the vector because of a previous trial/full offer bool bAlreadyInQueue=false; @@ -8599,7 +8665,7 @@ unsigned int CMinecraftApp::AddTMSPPFileTypeRequest(eDLCContentType eType, bool } if(!bAlreadyInQueue) - { + { TMSPPRequest *pTMSPPreq = new TMSPPRequest; pTMSPPreq->CallbackFunc=&CMinecraftApp::TMSPPFileReturned; @@ -8611,7 +8677,7 @@ unsigned int CMinecraftApp::AddTMSPPFileTypeRequest(eDLCContentType eType, bool pTMSPPreq->eState=e_TMS_ContentState_Queued; m_bAllTMSContentRetrieved=false; m_TMSPPDownloadQueue.push_back(pTMSPPreq); - } + } } else { @@ -8635,20 +8701,20 @@ unsigned int CMinecraftApp::AddTMSPPFileTypeRequest(eDLCContentType eType, bool // is this the right type? if(pDLC->eDLCType==eType) - { + { 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 - // is the file in the TMS XZP? + // is the file in the TMS XZP? //int iIndex = app.GetLocalTMSFileIndex(cString,true); //if(iIndex!=-1) - { - bool bPresent = app.IsFileInMemoryTextures(cString); + { + bool bPresent = app.IsFileInMemoryTextures(cString); if(!bPresent) // retrieve it from TMSPP - { + { bool bAlreadyInQueue=false; for( TMSPPRequest *pCurrent : m_TMSPPDownloadQueue ) { @@ -8660,7 +8726,7 @@ unsigned int CMinecraftApp::AddTMSPPFileTypeRequest(eDLCContentType eType, bool } if(!bAlreadyInQueue) - { + { TMSPPRequest *pTMSPPreq = new TMSPPRequest; pTMSPPreq->CallbackFunc=&CMinecraftApp::TMSPPFileReturned; @@ -8673,7 +8739,7 @@ unsigned int CMinecraftApp::AddTMSPPFileTypeRequest(eDLCContentType eType, bool pTMSPPreq->eState=e_TMS_ContentState_Queued; m_bAllTMSContentRetrieved=false; - m_TMSPPDownloadQueue.push_back(pTMSPPreq); + m_TMSPPDownloadQueue.push_back(pTMSPPreq); app.DebugPrintf("===m_TMSPPDownloadQueue Adding %ls, q size is %d\n",pTMSPPreq->wchFilename,m_TMSPPDownloadQueue.size()); } } @@ -8697,11 +8763,11 @@ unsigned int CMinecraftApp::AddTMSPPFileTypeRequest(eDLCContentType eType, bool //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 bool bAlreadyInQueue=false; @@ -8715,7 +8781,7 @@ unsigned int CMinecraftApp::AddTMSPPFileTypeRequest(eDLCContentType eType, bool } if(!bAlreadyInQueue) - { + { //app.DebugPrintf("Adding a request to the TMSPP download queue - %ls\n",pDLC->wchBanner); TMSPPRequest *pTMSPPreq = new TMSPPRequest; ZeroMemory(pTMSPPreq,sizeof(TMSPPRequest)); @@ -8734,7 +8800,7 @@ unsigned int CMinecraftApp::AddTMSPPFileTypeRequest(eDLCContentType eType, bool m_bAllTMSContentRetrieved=false; m_TMSPPDownloadQueue.push_back(pTMSPPreq); app.DebugPrintf("===m_TMSPPDownloadQueue Adding %ls, q size is %d\n",pTMSPPreq->wchFilename,m_TMSPPDownloadQueue.size()); - } + } } } } @@ -8825,7 +8891,7 @@ int CMinecraftApp::TMSPPFileReturned(LPVOID pParam,int iPad,int iUserData,C4JSto { #endif - CMinecraftApp* pClass = (CMinecraftApp *) pParam; + CMinecraftApp* pClass = static_cast<CMinecraftApp *>(pParam); // find the right one in the vector EnterCriticalSection(&pClass->csTMSPPDownloadQueue); @@ -8844,16 +8910,15 @@ int CMinecraftApp::TMSPPFileReturned(LPVOID pParam,int iPad,int iUserData,C4JSto // set this to retrieved whether it found it or not pCurrent->eState=e_TMS_ContentState_Retrieved; - if(pFileData!=NULL) + if(pFileData!=nullptr) { - #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 PBYTE pbData = new BYTE [pFileData->dwSize]; memcpy(pbData,pFileData->pbData,pFileData->dwSize); @@ -8862,13 +8927,13 @@ int CMinecraftApp::TMSPPFileReturned(LPVOID pParam,int iPad,int iUserData,C4JSto 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->dwSize); + app.AddMemoryTPDFile(iConfig, pbData, pFileData->dwSize); } 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 PBYTE pbData = new BYTE [pFileData->dwSize]; memcpy(pbData,pFileData->pbData,pFileData->dwSize); @@ -8888,11 +8953,11 @@ int CMinecraftApp::TMSPPFileReturned(LPVOID pParam,int iPad,int iUserData,C4JSto 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->dwSize); + app.AddMemoryTPDFile(iConfig, pFileData->pbData, pFileData->dwSize); } break; default: @@ -9086,7 +9151,7 @@ void CMinecraftApp::ClearTMSPPFilesRetrieved() int CMinecraftApp::DLCOffersReturned(void *pParam, int iOfferC, DWORD dwType, int iPad) { - CMinecraftApp* pClass = (CMinecraftApp *) pParam; + CMinecraftApp* pClass = static_cast<CMinecraftApp *>(pParam); // find the right one in the vector EnterCriticalSection(&pClass->csTMSPPDownloadQueue); @@ -9111,10 +9176,10 @@ eDLCContentType CMinecraftApp::Find_eDLCContentType(DWORD dwType) { if(m_dwContentTypeA[i]==dwType) { - return (eDLCContentType)i; + return static_cast<eDLCContentType>(i); } } - return (eDLCContentType)0; + return static_cast<eDLCContentType>(0); } bool CMinecraftApp::DLCContentRetrieved(eDLCMarketplaceType eType) { @@ -9149,7 +9214,7 @@ void CMinecraftApp::SetAdditionalSkinBoxes(DWORD dwSkinID, SKIN_BOX *SkinBoxA, D 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]); @@ -9179,7 +9244,7 @@ vector<ModelPart *> * CMinecraftApp::SetAdditionalSkinBoxes(DWORD dwSkinID, vect for( auto& it : *pvSkinBoxA ) { if(pModel) - { + { ModelPart *pModelPart=pModel->AddOrRetrievePart(it); pvModelPart->push_back(pModelPart); } @@ -9197,7 +9262,7 @@ vector<ModelPart *> * CMinecraftApp::SetAdditionalSkinBoxes(DWORD dwSkinID, vect vector<ModelPart *> *CMinecraftApp::GetAdditionalModelParts(DWORD dwSkinID) { EnterCriticalSection( &csAdditionalModelParts ); - vector<ModelPart *> *pvModelParts=NULL; + vector<ModelPart *> *pvModelParts=nullptr; if(m_AdditionalModelParts.size()>0) { auto it = m_AdditionalModelParts.find(dwSkinID); @@ -9214,7 +9279,7 @@ vector<ModelPart *> *CMinecraftApp::GetAdditionalModelParts(DWORD dwSkinID) vector<SKIN_BOX *> *CMinecraftApp::GetAdditionalSkinBoxes(DWORD dwSkinID) { EnterCriticalSection( &csAdditionalSkinBoxes ); - vector<SKIN_BOX *> *pvSkinBoxes=NULL; + vector<SKIN_BOX *> *pvSkinBoxes=nullptr; if(m_AdditionalSkinBoxes.size()>0) { auto it = m_AdditionalSkinBoxes.find(dwSkinID); @@ -9266,7 +9331,7 @@ void CMinecraftApp::SetAnimOverrideBitmask(DWORD dwSkinID,unsigned int uiAnimOve DWORD CMinecraftApp::getSkinIdFromPath(const wstring &skin) { - bool dlcSkin = false; + bool dlcSkin = false; unsigned int skinId = 0; if(skin.size() >= 14) @@ -9318,95 +9383,92 @@ wstring CMinecraftApp::getSkinPathFromId(DWORD skinId) } -int CMinecraftApp::TexturePackDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) +int CMinecraftApp::TexturePackDialogReturned(void* pParam, int iPad, C4JStorage::EMessageResult result) { - #if defined __PSVITA__ || defined __PS3__ || defined __ORBIS__ - if(result==C4JStorage::EMessage_ResultAccept) - { - Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->skins->selectTexturePackById(app.GetRequiredTexturePackID()) ) - { - // it's been installed already - } - else - { - // we need to enable background downloading for the DLC - XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_ALWAYS_ALLOW); - SONYDLC *pSONYDLCInfo=app.GetSONYDLCInfo(app.GetRequiredTexturePackID()); - if(pSONYDLCInfo!=NULL) - { - char chName[42]; - char chKeyName[20]; - char chSkuID[SCE_NP_COMMERCE2_SKU_ID_LEN]; - - memset(chSkuID,0,SCE_NP_COMMERCE2_SKU_ID_LEN); - // we have to retrieve the skuid from the store info, it can't be hardcoded since Sony may change it. - // So we assume the first sku for the product is the one we want - // MGH - keyname in the DLC file is 16 chars long, but there's no space for a NULL terminating char - memset(chKeyName, 0, sizeof(chKeyName)); - strncpy(chKeyName, pSONYDLCInfo->chDLCKeyname, 16); - - #ifdef __ORBIS__ - strcpy(chName, chKeyName); - #else - sprintf(chName,"%s-%s",app.GetCommerceCategory(),chKeyName); - #endif - app.GetDLCSkuIDFromProductList(chName,chSkuID); - // 4J-PB - need to check for an empty store - if(app.CheckForEmptyStore(iPad)==false) - { - if(app.DLCAlreadyPurchased(chSkuID)) - { - app.DownloadAlreadyPurchased(chSkuID); - } - else - { - app.Checkout(chSkuID); - } - } - } - } - } - else - { - app.DebugPrintf("Continuing without installing texture pack\n"); - } + if (result == C4JStorage::EMessage_ResultAccept) + { + Minecraft* pMinecraft = Minecraft::GetInstance(); + if (pMinecraft->skins->selectTexturePackById(app.GetRequiredTexturePackID())) + { + // it's been installed already + } + else + { + // we need to enable background downloading for the DLC + XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_ALWAYS_ALLOW); + + SONYDLC* pSONYDLCInfo = app.GetSONYDLCInfo(app.GetRequiredTexturePackID()); + if (pSONYDLCInfo != nullptr) + { + char chName[42]; + char chKeyName[20]; + char chSkuID[SCE_NP_COMMERCE2_SKU_ID_LEN]; + + memset(chSkuID, 0, SCE_NP_COMMERCE2_SKU_ID_LEN); + + memset(chKeyName, 0, sizeof(chKeyName)); + strncpy(chKeyName, pSONYDLCInfo->chDLCKeyname, 16); + + #ifdef __ORBIS__ + strcpy(chName, chKeyName); + #else + sprintf(chName, "%s-%s", app.GetCommerceCategory(), chKeyName); + #endif + + app.GetDLCSkuIDFromProductList(chName, chSkuID); + + if (app.CheckForEmptyStore(iPad) == false) + { + if (app.DLCAlreadyPurchased(chSkuID)) + { + app.DownloadAlreadyPurchased(chSkuID); + } + else + { + app.Checkout(chSkuID); + } + } + } + } + } + else + { + app.DebugPrintf("Continuing without installing texture pack\n"); + } #endif #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); - - 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_Cancelled) + { + if (app.GetRequiredTexturePackID() != 0) + { + XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_ALWAYS_ALLOW); + + ULONGLONG ullOfferID_Full; + ULONGLONG ullIndexA[1]; + app.GetDLCFullOfferIDForPackID(app.GetRequiredTexturePackID(), &ullOfferID_Full); + + if (result == C4JStorage::EMessage_ResultAccept) + { + ullIndexA[0] = ullOfferID_Full; + StorageManager.InstallOffer(1, ullIndexA, nullptr, nullptr); + } + else + { + DLC_INFO* pDLCInfo = app.GetDLCInfoForFullOfferID(ullOfferID_Full); + ullIndexA[0] = pDLCInfo->ullOfferID_Trial; + StorageManager.InstallOffer(1, ullIndexA, nullptr, nullptr); + } + } + } #endif - return 0; + return 0; } - int CMinecraftApp::getArchiveFileSize(const wstring &filename) { - TexturePack *tPack = NULL; + TexturePack *tPack = nullptr; Minecraft *pMinecraft = Minecraft::GetInstance(); if(pMinecraft && pMinecraft->skins) tPack = pMinecraft->skins->getSelected(); if(tPack && tPack->hasData() && tPack->getArchiveFile() && tPack->getArchiveFile()->hasFile(filename)) @@ -9418,7 +9480,7 @@ int CMinecraftApp::getArchiveFileSize(const wstring &filename) bool CMinecraftApp::hasArchiveFile(const wstring &filename) { - TexturePack *tPack = NULL; + TexturePack *tPack = nullptr; Minecraft *pMinecraft = Minecraft::GetInstance(); if(pMinecraft && pMinecraft->skins) tPack = pMinecraft->skins->getSelected(); if(tPack && tPack->hasData() && tPack->getArchiveFile() && tPack->getArchiveFile()->hasFile(filename)) return true; @@ -9427,7 +9489,7 @@ bool CMinecraftApp::hasArchiveFile(const wstring &filename) byteArray CMinecraftApp::getArchiveFile(const wstring &filename) { - TexturePack *tPack = NULL; + TexturePack *tPack = nullptr; Minecraft *pMinecraft = Minecraft::GetInstance(); if(pMinecraft && pMinecraft->skins) tPack = pMinecraft->skins->getSelected(); if(tPack && tPack->hasData() && tPack->getArchiveFile() && tPack->getArchiveFile()->hasFile(filename)) @@ -9440,39 +9502,39 @@ byteArray CMinecraftApp::getArchiveFile(const wstring &filename) // DLC #if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__) -int CMinecraftApp::GetDLCInfoCount() -{ +int CMinecraftApp::GetDLCInfoCount() +{ return (int)DLCInfo.size(); } #elif defined _XBOX_ONE -int CMinecraftApp::GetDLCInfoTrialOffersCount() -{ +int CMinecraftApp::GetDLCInfoTrialOffersCount() +{ return 0; } -int CMinecraftApp::GetDLCInfoFullOffersCount() -{ +int CMinecraftApp::GetDLCInfoFullOffersCount() +{ return (int)DLCInfo_Full.size(); } #else -int CMinecraftApp::GetDLCInfoTrialOffersCount() +int CMinecraftApp::GetDLCInfoTrialOffersCount() { - return (int)DLCInfo_Trial.size(); + return static_cast<int>(DLCInfo_Trial.size()); } int CMinecraftApp::GetDLCInfoFullOffersCount() { - return (int)DLCInfo_Full.size(); + return static_cast<int>(DLCInfo_Full.size()); } #endif -int CMinecraftApp::GetDLCInfoTexturesOffersCount() +int CMinecraftApp::GetDLCInfoTexturesOffersCount() { - return (int)DLCTextures_PackID.size(); + return static_cast<int>(DLCTextures_PackID.size()); } // AUTOSAVE -void CMinecraftApp::SetAutosaveTimerTime(void) +void CMinecraftApp::SetAutosaveTimerTime(void) { #if defined(_XBOX_ONE) || defined(__ORBIS__) m_uiAutosaveTimer= GetTickCount()+1000*60; @@ -9481,23 +9543,23 @@ void CMinecraftApp::SetAutosaveTimerTime(void) #endif }// value x 15 to get mins, x60 for secs -bool CMinecraftApp::AutosaveDue(void) -{ +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) +void CMinecraftApp::SetTrialTimerStart(void) { m_fTrialTimerStart=m_Time.fAppTime; mfTrialPausedTime=0.0f; } -float CMinecraftApp::getTrialTimer(void) -{ +float CMinecraftApp::getTrialTimer(void) +{ return m_Time.fAppTime-m_fTrialTimerStart-mfTrialPausedTime; } @@ -9532,7 +9594,7 @@ bool CMinecraftApp::IsLocalMultiplayerAvailable() //#else // for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) // { - // if( (i!=userIndex) && (InputManager.IsPadConnected(i) || ProfileManager.IsSignedIn(i)) ) + // if( (i!=userIndex) && (InputManager.IsPadConnected(i) || ProfileManager.IsSignedIn(i)) ) // { // iOtherConnectedControllers++; // } @@ -9607,7 +9669,7 @@ void CMinecraftApp::getLocale(vector<wstring> &vecWstrLocales) case XC_LOCALE_UNITED_ARAB_EMIRATES: case XC_LOCALE_GREAT_BRITAIN: locales.push_back(eMCLang_enGB); - break; + break; default: //XC_LOCALE_UNITED_STATES break; } @@ -9707,7 +9769,7 @@ void CMinecraftApp::getLocale(vector<wstring> &vecWstrLocales) break; case XC_LANGUAGE_BNORWEGIAN : locales.push_back(eMCLang_nbNO); - locales.push_back(eMCLang_noNO); + locales.push_back(eMCLang_noNO); locales.push_back(eMCLang_nnNO); break; case XC_LANGUAGE_DUTCH : @@ -9768,7 +9830,7 @@ void CMinecraftApp::getLocale(vector<wstring> &vecWstrLocales) locales.push_back(eMCLang_enUS); locales.push_back(eMCLang_null); - for (int i=0; i<locales.size(); i++) + for (size_t i=0; i<locales.size(); i++) { eMCLang lang = locales.at(i); vecWstrLocales.push_back( m_localeA[lang] ); |
