the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 711 lines 25 kB view raw
1#include "stdafx.h" 2#include "IUIScene_PauseMenu.h" 3#include "..\..\Minecraft.h" 4#include "..\..\MinecraftServer.h" 5#include "..\..\MultiPlayerLevel.h" 6#include "..\..\ProgressRenderer.h" 7#include "..\..\..\Minecraft.World\net.minecraft.world.level.h" 8#include "..\..\..\Minecraft.World\net.minecraft.world.phys.h" 9#include "..\..\TexturePackRepository.h" 10#include "..\..\TexturePack.h" 11#include "..\..\DLCTexturePack.h" 12#include "..\..\..\Minecraft.World\StringHelpers.h" 13 14#ifndef _XBOX 15#include "UI.h" 16#endif 17 18 19int IUIScene_PauseMenu::ExitGameDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) 20{ 21#ifdef _XBOX 22 IUIScene_PauseMenu *pScene = (IUIScene_PauseMenu *)pParam; 23#else 24 IUIScene_PauseMenu *pScene = dynamic_cast<IUIScene_PauseMenu *>(ui.GetSceneFromCallbackId((size_t)pParam)); 25#endif 26 27 // Results switched for this dialog 28 if(result==C4JStorage::EMessage_ResultDecline) 29 { 30 if(pScene) pScene->SetIgnoreInput(true); 31 app.SetAction(iPad,eAppAction_ExitWorld); 32 } 33 return 0; 34} 35 36 37int IUIScene_PauseMenu::ExitGameSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) 38{ 39#ifdef _XBOX 40 IUIScene_PauseMenu *pScene = (IUIScene_PauseMenu *)pParam; 41#else 42 IUIScene_PauseMenu *pScene = dynamic_cast<IUIScene_PauseMenu *>(ui.GetSceneFromCallbackId((size_t)pParam)); 43#endif 44 45 // Exit with or without saving 46 // Decline means save in this dialog 47 if(result==C4JStorage::EMessage_ResultDecline || result==C4JStorage::EMessage_ResultThirdOption) 48 { 49 if( result==C4JStorage::EMessage_ResultDecline ) // Save 50 { 51 // 4J-PB - Is the player trying to save but they are using a trial texturepack ? 52 if(!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) 53 { 54 TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected(); 55 DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack; 56 57 DLCPack *pDLCPack=pDLCTexPack->getDLCInfoParentPack();//tPack->getDLCPack(); 58 if(!pDLCPack->hasPurchasedFile( DLCManager::e_DLCType_Texture, L"" )) 59 { 60#ifdef _XBOX 61 // upsell 62 ULONGLONG ullOfferID_Full; 63 // get the dlc texture pack 64 DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack; 65 66 app.GetDLCFullOfferIDForPackID(pDLCTexPack->getDLCParentPackId(),&ullOfferID_Full); 67 68 // tell sentient about the upsell of the full version of the skin pack 69 TelemetryManager->RecordUpsellPresented(iPad, eSet_UpsellID_Texture_DLC, ullOfferID_Full & 0xFFFFFFFF); 70#endif 71 72 UINT uiIDA[2]; 73 uiIDA[0]=IDS_CONFIRM_OK; 74 uiIDA[1]=IDS_CONFIRM_CANCEL; 75 76 // Give the player a warning about the trial version of the texture pack 77 ui.RequestAlertMessage(IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, IDS_WARNING_DLC_TRIALTEXTUREPACK_TEXT, uiIDA, 2, ProfileManager.GetPrimaryPad() , &IUIScene_PauseMenu::WarningTrialTexturePackReturned, pParam); 78 79 return S_OK; 80 } 81 } 82 83 // does the save exist? 84 bool bSaveExists; 85 StorageManager.DoesSaveExist(&bSaveExists); 86 // 4J-PB - we check if the save exists inside the libs 87 // we need to ask if they are sure they want to overwrite the existing game 88 if(bSaveExists) 89 { 90 UINT uiIDA[2]; 91 uiIDA[0]=IDS_CONFIRM_CANCEL; 92 uiIDA[1]=IDS_CONFIRM_OK; 93 ui.RequestAlertMessage(IDS_TITLE_SAVE_GAME, IDS_CONFIRM_SAVE_GAME, uiIDA, 2, ProfileManager.GetPrimaryPad(), &IUIScene_PauseMenu::ExitGameAndSaveReturned, pParam); 94 return 0; 95 } 96 else 97 { 98#if defined(_XBOX_ONE) || defined(__ORBIS__) 99 StorageManager.SetSaveDisabled(false); 100#endif 101 MinecraftServer::getInstance()->setSaveOnExit( true ); 102 } 103 } 104 else 105 { 106 // been a few requests for a confirm on exit without saving 107 UINT uiIDA[2]; 108 uiIDA[0]=IDS_CONFIRM_CANCEL; 109 uiIDA[1]=IDS_CONFIRM_OK; 110 ui.RequestAlertMessage(IDS_TITLE_DECLINE_SAVE_GAME, IDS_CONFIRM_DECLINE_SAVE_GAME, uiIDA, 2, ProfileManager.GetPrimaryPad(), &IUIScene_PauseMenu::ExitGameDeclineSaveReturned, pParam); 111 return 0; 112 } 113 114 if(pScene) pScene->SetIgnoreInput(true); 115 116 app.SetAction(iPad,eAppAction_ExitWorld); 117 } 118 return 0; 119} 120 121 122int IUIScene_PauseMenu::ExitGameAndSaveReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) 123{ 124 // 4J-PB - we won't come in here if we have a trial texture pack 125#ifdef _XBOX 126 IUIScene_PauseMenu *pScene = (IUIScene_PauseMenu *)pParam; 127#else 128 IUIScene_PauseMenu *pScene = dynamic_cast<IUIScene_PauseMenu *>(ui.GetSceneFromCallbackId((size_t)pParam)); 129#endif 130 131 // results switched for this dialog 132 if(result==C4JStorage::EMessage_ResultDecline) 133 { 134 //INT saveOrCheckpointId = 0; 135 //bool validSave = StorageManager.GetSaveUniqueNumber(&saveOrCheckpointId); 136 //SentientManager.RecordLevelSaveOrCheckpoint(ProfileManager.GetPrimaryPad(), saveOrCheckpointId); 137#if defined(_XBOX_ONE) || defined(__ORBIS__) 138 StorageManager.SetSaveDisabled(false); 139#endif 140 if(pScene) pScene->SetIgnoreInput(true); 141 MinecraftServer::getInstance()->setSaveOnExit( true ); 142 // flag a app action of exit game 143 app.SetAction(iPad,eAppAction_ExitWorld); 144 } 145 else 146 { 147 // has someone disconnected the ethernet here, causing the pause menu to shut? 148 if(ui.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad())) 149 { 150 UINT uiIDA[3]; 151 // you cancelled the save on exit after choosing exit and save? You go back to the Exit choices then. 152 uiIDA[0]=IDS_CONFIRM_CANCEL; 153 uiIDA[1]=IDS_EXIT_GAME_SAVE; 154 uiIDA[2]=IDS_EXIT_GAME_NO_SAVE; 155 156 if(g_NetworkManager.GetPlayerCount()>1) 157 { 158 ui.RequestAlertMessage(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_CONFIRM_DISCONNECT_SAVE, uiIDA, 3, ProfileManager.GetPrimaryPad(), &IUIScene_PauseMenu::ExitGameSaveDialogReturned, pParam); 159 } 160 else 161 { 162 ui.RequestAlertMessage(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 3, ProfileManager.GetPrimaryPad(), &IUIScene_PauseMenu::ExitGameSaveDialogReturned, pParam); 163 } 164 } 165 } 166 return 0; 167} 168 169 170 171int IUIScene_PauseMenu::ExitGameDeclineSaveReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) 172{ 173#ifdef _XBOX 174 IUIScene_PauseMenu *pScene = (IUIScene_PauseMenu *)pParam; 175#else 176 IUIScene_PauseMenu *pScene = dynamic_cast<IUIScene_PauseMenu *>(ui.GetSceneFromCallbackId((size_t)pParam)); 177#endif 178 179 // results switched for this dialog 180 if(result==C4JStorage::EMessage_ResultDecline) 181 { 182#if defined(_XBOX_ONE) || defined(__ORBIS__) 183 // Don't do this here, as it will still try and save some things even though it shouldn't! 184 //StorageManager.SetSaveDisabled(false); 185#endif 186 if(pScene) pScene->SetIgnoreInput(true); 187 MinecraftServer::getInstance()->setSaveOnExit( false ); 188 // flag a app action of exit game 189 app.SetAction(iPad,eAppAction_ExitWorld); 190 } 191 else 192 { 193 // has someone disconnected the ethernet here, causing the pause menu to shut? 194 if(ui.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad())) 195 { 196 UINT uiIDA[3]; 197 // you cancelled the save on exit after choosing exit and save? You go back to the Exit choices then. 198 uiIDA[0]=IDS_CONFIRM_CANCEL; 199 uiIDA[1]=IDS_EXIT_GAME_SAVE; 200 uiIDA[2]=IDS_EXIT_GAME_NO_SAVE; 201 202 if(g_NetworkManager.GetPlayerCount()>1) 203 { 204 ui.RequestAlertMessage(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_CONFIRM_DISCONNECT_SAVE, uiIDA, 3, ProfileManager.GetPrimaryPad(),&IUIScene_PauseMenu::ExitGameSaveDialogReturned, pParam); 205 } 206 else 207 { 208 ui.RequestAlertMessage(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 3, ProfileManager.GetPrimaryPad(),&IUIScene_PauseMenu::ExitGameSaveDialogReturned, pParam); 209 } 210 } 211 212 } 213 return 0; 214} 215 216 217 218int IUIScene_PauseMenu::WarningTrialTexturePackReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) 219{ 220#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) 221 if(result==C4JStorage::EMessage_ResultAccept) 222 { 223 if(!ProfileManager.IsSignedInLive(iPad)) 224 { 225 // you're not signed in to PSN! 226 227 } 228 else 229 { 230 // 4J-PB - need to check this user can access the store 231 bool bContentRestricted; 232 ProfileManager.GetChatAndContentRestrictions(iPad,true,NULL,&bContentRestricted,NULL); 233 if(bContentRestricted) 234 { 235 UINT uiIDA[1]; 236 uiIDA[0]=IDS_CONFIRM_OK; 237 ui.RequestAlertMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, iPad); 238 } 239 else 240 { 241 // need to get info on the pack to see if the user has already downloaded it 242 TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected(); 243 DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack; 244 245 // retrieve the store name for the skin pack 246 DLCPack *pDLCPack=pDLCTexPack->getDLCInfoParentPack();//tPack->getDLCPack(); 247 const char *pchPackName=wstringtofilename(pDLCPack->getName()); 248 app.DebugPrintf("Texture Pack - %s\n",pchPackName); 249 SONYDLC *pSONYDLCInfo=app.GetSONYDLCInfo((char *)pchPackName); 250 251 if(pSONYDLCInfo!=NULL) 252 { 253 char chName[42]; 254 char chSkuID[SCE_NP_COMMERCE2_SKU_ID_LEN]; 255 256 memset(chSkuID,0,SCE_NP_COMMERCE2_SKU_ID_LEN); 257 // find the info on the skin pack 258 // we have to retrieve the skuid from the store info, it can't be hardcoded since Sony may change it. 259 // So we assume the first sku for the product is the one we want 260#ifdef __ORBIS__ 261 sprintf(chName,"%s",pSONYDLCInfo->chDLCKeyname); 262#else 263 sprintf(chName,"%s-%s",app.GetCommerceCategory(),pSONYDLCInfo->chDLCKeyname); 264#endif 265 app.GetDLCSkuIDFromProductList(chName,chSkuID); 266 // 4J-PB - need to check for an empty store 267#if defined __ORBIS__ || defined __PSVITA__ || defined __PS3__ 268 if(app.CheckForEmptyStore(iPad)==false) 269#endif 270 { 271 if(app.DLCAlreadyPurchased(chSkuID)) 272 { 273 app.DownloadAlreadyPurchased(chSkuID); 274 } 275 else 276 { 277 app.Checkout(chSkuID); 278 } 279 } 280 } 281 } 282 } 283 } 284#endif // 285 286#ifdef _XBOX_ONE 287 IUIScene_PauseMenu* pScene = (IUIScene_PauseMenu*)pParam; 288 289 if(result==C4JStorage::EMessage_ResultAccept) 290 { 291 if(ProfileManager.IsSignedIn(iPad)) 292 { 293 if (ProfileManager.IsSignedInLive(iPad)) 294 { 295 TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected(); 296 // get the dlc texture pack 297 DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack; 298 299 DLCPack *pDLCPack=pDLCTexPack->getDLCInfoParentPack(); 300 301 DLC_INFO *pDLCInfo=app.GetDLCInfoForProductName((WCHAR *)pDLCPack->getName().c_str()); 302 303 StorageManager.InstallOffer(1,(WCHAR *)pDLCInfo->wsProductId.c_str(),NULL,NULL); 304 305 // the license change coming in when the offer has been installed will cause this scene to refresh 306 } 307 else 308 { 309 // 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. 310 UINT uiIDA[1] = { IDS_CONFIRM_OK }; 311 ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, iPad); 312 } 313 } 314 } 315 316#endif 317 318#ifdef _XBOX 319 IUIScene_PauseMenu* pScene = (IUIScene_PauseMenu*)pParam; 320 321 //pScene->m_bIgnoreInput = false; 322 pScene->ShowScene( true ); 323 if(result==C4JStorage::EMessage_ResultAccept) 324 { 325 if(ProfileManager.IsSignedIn(iPad)) 326 { 327 ULONGLONG ullIndexA[1]; 328 329 TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected(); 330 // get the dlc texture pack 331 DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack; 332 333 // Need to get the parent packs id, since this may be one of many child packs with their own ids 334 app.GetDLCFullOfferIDForPackID(pDLCTexPack->getDLCParentPackId(),&ullIndexA[0]); 335 336 // 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... 337 XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_ALWAYS_ALLOW); 338 339 StorageManager.InstallOffer(1,ullIndexA,NULL,NULL); 340 } 341 } 342 else 343 { 344 TelemetryManager->RecordUpsellResponded(iPad, eSet_UpsellID_Texture_DLC, ( pScene->m_pDLCPack->getPurchaseOfferId() & 0xFFFFFFFF ), eSen_UpsellOutcome_Declined); 345 } 346#endif 347 348 349 return 0; 350} 351 352 353int IUIScene_PauseMenu::SaveWorldThreadProc( LPVOID lpParameter ) 354{ 355 bool bAutosave=(bool)lpParameter; 356 if(bAutosave) 357 { 358 app.SetXuiServerAction(ProfileManager.GetPrimaryPad(),eXuiServerAction_AutoSaveGame); 359 } 360 else 361 { 362 app.SetXuiServerAction(ProfileManager.GetPrimaryPad(),eXuiServerAction_SaveGame); 363 } 364 365 // Share AABB & Vec3 pools with default (main thread) - should be ok as long as we don't tick the main thread whilst this thread is running 366 AABB::UseDefaultThreadStorage(); 367 Vec3::UseDefaultThreadStorage(); 368 Compression::UseDefaultThreadStorage(); 369 370 Minecraft *pMinecraft=Minecraft::GetInstance(); 371 372 //wprintf(L"Loading world on thread\n"); 373 374 if(ProfileManager.IsFullVersion()) 375 { 376 app.SetGameStarted(false); 377 378 while( app.GetXuiServerAction(ProfileManager.GetPrimaryPad() ) != eXuiServerAction_Idle && !MinecraftServer::serverHalted() ) 379 { 380 Sleep(10); 381 } 382 383 if(!MinecraftServer::serverHalted() && !app.GetChangingSessionType() ) app.SetGameStarted(true); 384 385#if defined(_XBOX_ONE) || defined(__ORBIS__) 386 if(app.GetGameHostOption(eGameHostOption_DisableSaving)) StorageManager.SetSaveDisabled(true); 387#endif 388 } 389 390 HRESULT hr = S_OK; 391 if(app.GetChangingSessionType()) 392 { 393 // 4J Stu - This causes the fullscreenprogress scene to ignore the action it was given 394 hr = ERROR_CANCELLED; 395 } 396 return hr; 397} 398 399int IUIScene_PauseMenu::ExitWorldThreadProc( void* lpParameter ) 400{ 401 // Share AABB & Vec3 pools with default (main thread) - should be ok as long as we don't tick the main thread whilst this thread is running 402 AABB::UseDefaultThreadStorage(); 403 Vec3::UseDefaultThreadStorage(); 404 Compression::UseDefaultThreadStorage(); 405 406 //app.SetGameStarted(false); 407 408 _ExitWorld(lpParameter); 409 410 return S_OK; 411} 412 413// This function performs the meat of exiting from a level. It should be called from a thread other than the main thread. 414void IUIScene_PauseMenu::_ExitWorld(LPVOID lpParameter) 415{ 416 Minecraft *pMinecraft=Minecraft::GetInstance(); 417 418 int exitReasonStringId = pMinecraft->progressRenderer->getCurrentTitle(); 419 int exitReasonTitleId = IDS_CONNECTION_LOST; 420 421 bool saveStats = true; 422 if (pMinecraft->isClientSide() || g_NetworkManager.IsInSession()) 423 { 424 if(lpParameter != NULL ) 425 { 426 // 4J-PB - check if we have lost connection to Live 427 if(ProfileManager.GetLiveConnectionStatus()!=XONLINE_S_LOGON_CONNECTION_ESTABLISHED ) 428 { 429 exitReasonStringId = IDS_CONNECTION_LOST_LIVE; 430 } 431 else 432 { 433 switch( app.GetDisconnectReason() ) 434 { 435 case DisconnectPacket::eDisconnect_Kicked: 436 exitReasonStringId = IDS_DISCONNECTED_KICKED; 437 break; 438 case DisconnectPacket::eDisconnect_NoUGC_AllLocal: 439 exitReasonStringId = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_ALL_LOCAL; 440 exitReasonTitleId = IDS_CONNECTION_FAILED; 441 break; 442 case DisconnectPacket::eDisconnect_NoUGC_Single_Local: 443 exitReasonStringId = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_SINGLE_LOCAL; 444 exitReasonTitleId = IDS_CONNECTION_FAILED; 445 break; 446#if defined(__PS3__) || defined(__ORBIS__) 447 case DisconnectPacket::eDisconnect_ContentRestricted_AllLocal: 448 exitReasonStringId = IDS_CONTENT_RESTRICTION_MULTIPLAYER; 449 exitReasonTitleId = IDS_CONNECTION_FAILED; 450 break; 451 case DisconnectPacket::eDisconnect_ContentRestricted_Single_Local: 452 exitReasonStringId = IDS_CONTENT_RESTRICTION; 453 exitReasonTitleId = IDS_CONNECTION_FAILED; 454 break; 455#endif 456#ifdef _XBOX 457 case DisconnectPacket::eDisconnect_NoUGC_Remote: 458 exitReasonStringId = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_REMOTE; 459 exitReasonTitleId = IDS_CONNECTION_FAILED; 460 break; 461#endif 462 case DisconnectPacket::eDisconnect_NoFlying: 463 exitReasonStringId = IDS_DISCONNECTED_FLYING; 464 break; 465 case DisconnectPacket::eDisconnect_Quitting: 466 exitReasonStringId = IDS_DISCONNECTED_SERVER_QUIT; 467 break; 468#ifdef __ORBIS__ 469 case DisconnectPacket::eDisconnect_NetworkError: 470 exitReasonStringId = IDS_ERROR_NETWORK_EXIT; 471 exitReasonTitleId = IDS_ERROR_NETWORK_TITLE; 472 break; 473#endif 474 case DisconnectPacket::eDisconnect_NoFriendsInGame: 475 exitReasonStringId = IDS_DISCONNECTED_NO_FRIENDS_IN_GAME; 476 exitReasonTitleId = IDS_CANTJOIN_TITLE; 477 break; 478 case DisconnectPacket::eDisconnect_Banned: 479 exitReasonStringId = IDS_DISCONNECTED_BANNED; 480 exitReasonTitleId = IDS_CANTJOIN_TITLE; 481 break; 482 case DisconnectPacket::eDisconnect_NotFriendsWithHost: 483 exitReasonStringId = IDS_NOTALLOWED_FRIENDSOFFRIENDS; 484 exitReasonTitleId = IDS_CANTJOIN_TITLE; 485 break; 486 case DisconnectPacket::eDisconnect_OutdatedServer: 487 exitReasonStringId = IDS_DISCONNECTED_SERVER_OLD; 488 exitReasonTitleId = IDS_CANTJOIN_TITLE; 489 break; 490 case DisconnectPacket::eDisconnect_OutdatedClient: 491 exitReasonStringId = IDS_DISCONNECTED_CLIENT_OLD; 492 exitReasonTitleId = IDS_CANTJOIN_TITLE; 493 break; 494 case DisconnectPacket::eDisconnect_ServerFull: 495 exitReasonStringId = IDS_DISCONNECTED_SERVER_FULL; 496 exitReasonTitleId = IDS_CANTJOIN_TITLE; 497 break; 498#ifdef _XBOX_ONE 499 case DisconnectPacket::eDisconnect_ExitedGame: 500 exitReasonTitleId = IDS_EXIT_GAME; 501 exitReasonStringId = IDS_DISCONNECTED_EXITED_GAME; 502 break; 503#endif 504 505#if defined __ORBIS__ || defined __PS3__ || defined __PSVITA__ 506 case DisconnectPacket::eDisconnect_NATMismatch: 507 exitReasonStringId = IDS_DISCONNECTED_NAT_TYPE_MISMATCH; 508 exitReasonTitleId = IDS_CONNECTION_FAILED; 509 break; 510#endif 511 default: 512 exitReasonStringId = IDS_CONNECTION_LOST_SERVER; 513 } 514 } 515 //pMinecraft->progressRenderer->progressStartNoAbort( exitReasonStringId ); 516 517 UINT uiIDA[1]; 518 uiIDA[0]=IDS_CONFIRM_OK; 519 // 4J Stu - Fix for #48669 - TU5: Code: Compliance: TCR #15: Incorrect/misleading messages after signing out a profile during online game session. 520 // If the primary player is signed out, then that is most likely the cause of the disconnection so don't display a message box. This will allow the message box requested by the libraries to be brought up 521 if( ProfileManager.IsSignedIn(ProfileManager.GetPrimaryPad())) ui.RequestErrorMessage( exitReasonTitleId, exitReasonStringId, uiIDA,1,ProfileManager.GetPrimaryPad()); 522 exitReasonStringId = -1; 523 524 // 4J - Force a disconnection, this handles the situation that the server has already disconnected 525 if( pMinecraft->levels[0] != NULL ) pMinecraft->levels[0]->disconnect(false); 526 if( pMinecraft->levels[1] != NULL ) pMinecraft->levels[1]->disconnect(false); 527 if( pMinecraft->levels[2] != NULL ) pMinecraft->levels[2]->disconnect(false); 528 } 529 else 530 { 531 exitReasonStringId = IDS_EXITING_GAME; 532 pMinecraft->progressRenderer->progressStartNoAbort( IDS_EXITING_GAME ); 533 if( pMinecraft->levels[0] != NULL ) pMinecraft->levels[0]->disconnect(); 534 if( pMinecraft->levels[1] != NULL ) pMinecraft->levels[1]->disconnect(); 535 if( pMinecraft->levels[2] != NULL ) pMinecraft->levels[2]->disconnect(); 536 } 537 538 // 4J Stu - This only does something if we actually have a server, so don't need to do any other checks 539 MinecraftServer::HaltServer(); 540 541 // We need to call the stats & leaderboards save before we exit the session 542 // 4J We need to do this in a QNet callback where it is safe 543 //pMinecraft->forceStatsSave(); 544 saveStats = false; 545 546 // 4J Stu - Leave the session once the disconnect packet has been sent 547 g_NetworkManager.LeaveGame(FALSE); 548 } 549 else 550 { 551 if(lpParameter != NULL && ProfileManager.IsSignedIn(ProfileManager.GetPrimaryPad()) ) 552 { 553 switch( app.GetDisconnectReason() ) 554 { 555 case DisconnectPacket::eDisconnect_Kicked: 556 exitReasonStringId = IDS_DISCONNECTED_KICKED; 557 break; 558 case DisconnectPacket::eDisconnect_NoUGC_AllLocal: 559 exitReasonStringId = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_ALL_LOCAL; 560 exitReasonTitleId = IDS_CONNECTION_FAILED; 561 break; 562 case DisconnectPacket::eDisconnect_NoUGC_Single_Local: 563 exitReasonStringId = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_SINGLE_LOCAL; 564 exitReasonTitleId = IDS_CONNECTION_FAILED; 565 break; 566#if defined(__PS3__) || defined(__ORBIS__) 567 case DisconnectPacket::eDisconnect_ContentRestricted_AllLocal: 568 exitReasonStringId = IDS_CONTENT_RESTRICTION_MULTIPLAYER; 569 exitReasonTitleId = IDS_CONNECTION_FAILED; 570 break; 571 case DisconnectPacket::eDisconnect_ContentRestricted_Single_Local: 572 exitReasonStringId = IDS_CONTENT_RESTRICTION; 573 exitReasonTitleId = IDS_CONNECTION_FAILED; 574 break; 575#endif 576#ifdef _XBOX 577 case DisconnectPacket::eDisconnect_NoUGC_Remote: 578 exitReasonStringId = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_REMOTE; 579 exitReasonTitleId = IDS_CONNECTION_FAILED; 580 break; 581#endif 582 case DisconnectPacket::eDisconnect_Quitting: 583 exitReasonStringId = IDS_DISCONNECTED_SERVER_QUIT; 584 break; 585#ifdef __ORBIS__ 586 case DisconnectPacket::eDisconnect_NetworkError: 587 exitReasonStringId = IDS_ERROR_NETWORK_EXIT; 588 exitReasonTitleId = IDS_ERROR_NETWORK_TITLE; 589 break; 590#endif 591 case DisconnectPacket::eDisconnect_NoMultiplayerPrivilegesJoin: 592 exitReasonStringId = IDS_NO_MULTIPLAYER_PRIVILEGE_JOIN_TEXT; 593 break; 594 case DisconnectPacket::eDisconnect_OutdatedServer: 595 exitReasonStringId = IDS_DISCONNECTED_SERVER_OLD; 596 exitReasonTitleId = IDS_CANTJOIN_TITLE; 597 break; 598 case DisconnectPacket::eDisconnect_OutdatedClient: 599 exitReasonStringId = IDS_DISCONNECTED_CLIENT_OLD; 600 exitReasonTitleId = IDS_CANTJOIN_TITLE; 601 break; 602 case DisconnectPacket::eDisconnect_ServerFull: 603 exitReasonStringId = IDS_DISCONNECTED_SERVER_FULL; 604 exitReasonTitleId = IDS_CANTJOIN_TITLE; 605 break; 606#if defined __ORBIS__ || defined __PS3__ || defined __PSVITA__ 607 case DisconnectPacket::eDisconnect_NATMismatch: 608 exitReasonStringId = IDS_DISCONNECTED_NAT_TYPE_MISMATCH; 609 exitReasonTitleId = IDS_CONNECTION_FAILED; 610 break; 611#endif 612 default: 613 exitReasonStringId = IDS_DISCONNECTED; 614 } 615 //pMinecraft->progressRenderer->progressStartNoAbort( exitReasonStringId ); 616 617 UINT uiIDA[1]; 618 uiIDA[0]=IDS_CONFIRM_OK; 619 ui.RequestErrorMessage( exitReasonTitleId, exitReasonStringId, uiIDA,1,ProfileManager.GetPrimaryPad()); 620 exitReasonStringId = -1; 621 } 622 } 623 // Fix for #93148 - TCR 001: BAS Game Stability: Title will crash for the multiplayer client if host of the game will exit during the clients loading to created world. 624 while( g_NetworkManager.IsNetworkThreadRunning() ) 625 { 626 Sleep(1); 627 } 628 pMinecraft->setLevel(NULL,exitReasonStringId,nullptr,saveStats); 629 630 TelemetryManager->Flush(); 631 632 app.m_gameRules.unloadCurrentGameRules(); 633 //app.m_Audio.unloadCurrentAudioDetails(); 634 635 MinecraftServer::resetFlags(); 636 637 // Fix for #48385 - BLACK OPS :TU5: Functional: Client becomes pseudo soft-locked when returned to the main menu after a remote disconnect 638 // Make sure there is text explaining why the player is waiting 639 pMinecraft->progressRenderer->progressStart(IDS_EXITING_GAME); 640 641 // Fix for #13259 - CRASH: Gameplay: loading process is halted when player loads saved data 642 // We can't start/join a new game until the session is destroyed, so wait for it to be idle again 643 while( g_NetworkManager.IsInSession() ) 644 { 645 Sleep(1); 646 } 647 648 app.SetChangingSessionType(false); 649 app.SetReallyChangingSessionType(false); 650 651#if defined(_XBOX_ONE) || defined(__ORBIS__) 652 // Make sure we don't think saving is disabled in the menus 653 StorageManager.SetSaveDisabled(false); 654#endif 655} 656 657 658int IUIScene_PauseMenu::SaveGameDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) 659{ 660 // results switched for this dialog 661 if(result==C4JStorage::EMessage_ResultDecline) 662 { 663#if defined(_XBOX_ONE) || defined(__ORBIS__) 664 UINT uiIDA[2]; 665 uiIDA[0]=IDS_CONFIRM_CANCEL; 666 uiIDA[1]=IDS_CONFIRM_OK; 667 ui.RequestAlertMessage(IDS_TITLE_ENABLE_AUTOSAVE, IDS_CONFIRM_ENABLE_AUTOSAVE, uiIDA, 2, iPad,&IUIScene_PauseMenu::EnableAutosaveDialogReturned,pParam); 668#else 669 // flag a app action of save game 670 app.SetAction(iPad,eAppAction_SaveGame); 671#endif 672 } 673 return 0; 674} 675 676int IUIScene_PauseMenu::EnableAutosaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) 677{ 678 // results switched for this dialog 679 if(result==C4JStorage::EMessage_ResultDecline) 680 { 681 // Set the global flag, so that we don't disable saving again once the save is complete 682 app.SetGameHostOption(eGameHostOption_DisableSaving, 0); 683 } 684 else 685 { 686 // Set the global flag, so that we do disable saving again once the save is complete 687 // We need to set this on as we may have only disabled it due to having a trial texture pack 688 app.SetGameHostOption(eGameHostOption_DisableSaving, 1); 689 } 690 // Re-enable saving temporarily 691 StorageManager.SetSaveDisabled(false); 692 693 // flag a app action of save game 694 app.SetAction(iPad,eAppAction_SaveGame); 695 return 0; 696} 697 698int IUIScene_PauseMenu::DisableAutosaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) 699{ 700 // results switched for this dialog 701 if(result==C4JStorage::EMessage_ResultDecline) 702 { 703 // Set the global flag, so that we disable saving again once the save is complete 704 app.SetGameHostOption(eGameHostOption_DisableSaving, 1); 705 StorageManager.SetSaveDisabled(false); 706 707 // flag a app action of save game 708 app.SetAction(iPad,eAppAction_SaveGame); 709 } 710 return 0; 711}