From 57de83add1e2aafcdc5f41767e5e4194c52f58d7 Mon Sep 17 00:00:00 2001 From: SevenToaster509 Date: Sun, 26 Apr 2026 20:12:34 +0100 Subject: [PATCH] fix: achievements (2) Make menu more accurate Add Achievements option to Main Menu Force achievements to save when saving the level Fix a random crash i was getting --- .../Network/PlatformNetworkManagerStub.cpp | 6 +++++- Minecraft.Client/Common/UI/UIController.cpp | 2 +- .../Common/UI/UIScene_AchievementsMenu.cpp | 21 +++++++++++++------ .../Common/UI/UIScene_AchievementsMenu.h | 1 - .../Common/UI/UIScene_MainMenu.cpp | 1 + .../Common/UI/UIScene_PauseMenu.cpp | 1 + Minecraft.World/DirectoryLevelStorage.cpp | 2 ++ 7 files changed, 25 insertions(+), 9 deletions(-) diff --git a/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp b/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp index 6cb9a328..7e8d6910 100644 --- a/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp +++ b/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp @@ -929,7 +929,11 @@ void CPlatformNetworkManagerStub::SearchForGames() strncpy_s(info->data.hostIP, sizeof(info->data.hostIP), ipBuf, _TRUNCATE); info->data.hostPort = port; info->sessionId = static_cast(inet_addr(ipBuf)) | static_cast(port) << 32; - friendsSessions[0].push_back(info); + //Fix null crash? I think its here... + if (info) { + friendsSessions[0].push_back(info); + } + } } } diff --git a/Minecraft.Client/Common/UI/UIController.cpp b/Minecraft.Client/Common/UI/UIController.cpp index 0ba5f151..99a659c1 100644 --- a/Minecraft.Client/Common/UI/UIController.cpp +++ b/Minecraft.Client/Common/UI/UIController.cpp @@ -1916,7 +1916,7 @@ GDrawTexture * RADLINK UIController::TextureSubstitutionCreateCallback ( void * UIScene *scene = uiController->GetTopScene(0); //Fix for icon size changing on Achievements if (scene) { - if (scene->getSceneResolution() == UIScene::eSceneResolution_1080 && scene->getSceneType() != eUIScene_PauseMenu && isSub == false) + if (scene->getSceneResolution() == UIScene::eSceneResolution_1080 && (scene->getSceneType() != eUIScene_PauseMenu && scene->getSceneType() != eUIScene_MainMenu && scene->getSceneType() != eUIScene_AchievementsMenu) && isSub == false) { *width = 96; *height = 96; diff --git a/Minecraft.Client/Common/UI/UIScene_AchievementsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_AchievementsMenu.cpp index 09a1eb60..5006ca8b 100644 --- a/Minecraft.Client/Common/UI/UIScene_AchievementsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_AchievementsMenu.cpp @@ -16,13 +16,13 @@ UIScene_AchievementsMenu::UIScene_AchievementsMenu(int iPad, void* _initData, UI // Setup all the Iggy references we need for this scene initialiseMovie(); - RECT rc; + /*RECT rc; GetClientRect(g_hWnd, &rc); POINT center; center.x = rc.left; center.y = rc.top; ClientToScreen(g_hWnd, ¢er); - SetCursorPos(center.x, center.y); + SetCursorPos(center.x, center.y);*/ m_labelAchievements.init(L"Achievements"); //m_labelDesc.init(L""); @@ -46,7 +46,13 @@ UIScene_AchievementsMenu::UIScene_AchievementsMenu(int iPad, void* _initData, UI std::string result = "Graphics\\Achievements\\" "TROP" + Achievements::achievements->at(i)->iconInt + ".png"; //media\\ m_achievementsList.addnewItem(i+1, path); - if (Minecraft::GetInstance()->stats[Minecraft::GetInstance()->player->GetXboxPad()]->hasTaken(Achievements::achievements->at(i))) + + int newPad = 0; + if (Minecraft::GetInstance()->player != nullptr) { + newPad = Minecraft::GetInstance()->player->GetXboxPad(); + } + + if (Minecraft::GetInstance()->stats[newPad]->hasTaken(Achievements::achievements->at(i))) { m_achievementsList.EnableButton(i, true); } @@ -63,8 +69,7 @@ UIScene_AchievementsMenu::UIScene_AchievementsMenu(int iPad, void* _initData, UI void UIScene_AchievementsMenu::handleDestroy() { -#ifdef _WINDOWS64 -#endif + m_parentLayer->showComponent(m_iPad, eUIComponent_MenuBackground, false); } void UIScene_AchievementsMenu::SetAchievementDescription(wstring desc) { @@ -102,8 +107,12 @@ wstring UIScene_AchievementsMenu::getMoviePath() void UIScene_AchievementsMenu::updateComponents() { + bool bNotInGame = (Minecraft::GetInstance()->level == nullptr); + if (!bNotInGame) + { + m_parentLayer->showComponent(m_iPad, eUIComponent_MenuBackground, true); + } m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, false); - m_parentLayer->showComponent(m_iPad, eUIComponent_MenuBackground, false); } void UIScene_AchievementsMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool& handled) diff --git a/Minecraft.Client/Common/UI/UIScene_AchievementsMenu.h b/Minecraft.Client/Common/UI/UIScene_AchievementsMenu.h index e14a3764..01ecd11d 100644 --- a/Minecraft.Client/Common/UI/UIScene_AchievementsMenu.h +++ b/Minecraft.Client/Common/UI/UIScene_AchievementsMenu.h @@ -28,7 +28,6 @@ private: UI_MAP_ELEMENT(m_labelAchievements, "AcheivementsLabel") UI_MAP_ELEMENT(m_labelName, "AchievementName") UI_MAP_ELEMENT(m_labelDesc, "AchievementDescription") - UI_MAP_ELEMENT(m_cursorPath1, "cursor") //UI_MAP_ELEMENT(m_achievementsList, "AchievementsList") UI_MAP_ELEMENT(m_controlMainPanel, "AchievementsListContainer") UI_MAP_NAME(m_funcSetDesc, L"SetAchievementDescription") diff --git a/Minecraft.Client/Common/UI/UIScene_MainMenu.cpp b/Minecraft.Client/Common/UI/UIScene_MainMenu.cpp index de95eb43..d159a164 100644 --- a/Minecraft.Client/Common/UI/UIScene_MainMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_MainMenu.cpp @@ -2040,6 +2040,7 @@ void UIScene_MainMenu::RunAchievements(int iPad) XShowAchievementsUI( iPad ); } #endif + ui.NavigateToScene(iPad, eUIScene_AchievementsMenu); } void UIScene_MainMenu::RunHelpAndOptions(int iPad) diff --git a/Minecraft.Client/Common/UI/UIScene_PauseMenu.cpp b/Minecraft.Client/Common/UI/UIScene_PauseMenu.cpp index 28e37887..cf137320 100644 --- a/Minecraft.Client/Common/UI/UIScene_PauseMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_PauseMenu.cpp @@ -993,6 +993,7 @@ int UIScene_PauseMenu::UnlockFullSaveReturned(void *pParam,int iPad,C4JStorage:: ProfileManager.DisplayFullVersionPurchase(false,pMinecraft->player->GetXboxPad(),eSen_UpsellID_Full_Version_Of_Game); } } + pMinecraft->forceStatsSave(pMinecraft->player->GetXboxPad()); } else { diff --git a/Minecraft.World/DirectoryLevelStorage.cpp b/Minecraft.World/DirectoryLevelStorage.cpp index c557e37a..30ee52f0 100644 --- a/Minecraft.World/DirectoryLevelStorage.cpp +++ b/Minecraft.World/DirectoryLevelStorage.cpp @@ -11,6 +11,7 @@ #include "LevelData.h" #include "DirectoryLevelStorage.h" #include "ConsoleSaveFileIO.h" +#include "../Minecraft.Client/Minecraft.h" const wstring DirectoryLevelStorage::sc_szPlayerDir(L"players/"); @@ -391,6 +392,7 @@ void DirectoryLevelStorage::save(shared_ptr player) if( playerXuid != INVALID_XUID && !player->isGuest() ) #endif { + Minecraft::GetInstance()->forceStatsSave(player->getPlayerIndex()); CompoundTag *tag = new CompoundTag(); player->saveWithoutId(tag); #if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__)