diff --git a/Minecraft.Client/Common/Consoles_App.cpp b/Minecraft.Client/Common/Consoles_App.cpp index a2c944fc..ab46fa1c 100644 --- a/Minecraft.Client/Common/Consoles_App.cpp +++ b/Minecraft.Client/Common/Consoles_App.cpp @@ -71,6 +71,10 @@ #include "..\Common\Leaderboards\LeaderboardManager.h" +#ifdef _WINDOWS64 +#include "..\Windows64\Windows64_DiscordPresence.h" +#endif + //CMinecraftApp app; unsigned int CMinecraftApp::m_uiLastSignInData = 0; @@ -3105,11 +3109,19 @@ void CMinecraftApp::HandleXuiActions(void) { if(g_NetworkManager.IsLocalGame()) { - ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYEROFFLINE,false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MULTIPLAYEROFFLINE); + #else + ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYEROFFLINE,false); + #endif } else { - ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYER,false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MULTIPLAYER); + #else + ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYER,false); + #endif } } } @@ -3122,11 +3134,19 @@ void CMinecraftApp::HandleXuiActions(void) { if(g_NetworkManager.IsLocalGame()) { - ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE,false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE); + #else + ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE,false); + #endif } else { - ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYER_1P,false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MULTIPLAYER_1P); + #else + ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYER_1P,false); + #endif } } } @@ -3187,11 +3207,19 @@ void CMinecraftApp::HandleXuiActions(void) { if(g_NetworkManager.IsLocalGame()) { - ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYEROFFLINE,false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MULTIPLAYEROFFLINE); + #else + ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYEROFFLINE,false); + #endif } else { - ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYER,false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MULTIPLAYER); + #else + ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYER,false); + #endif } } } @@ -3204,11 +3232,19 @@ void CMinecraftApp::HandleXuiActions(void) { if(g_NetworkManager.IsLocalGame()) { - ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE,false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE); + #else + ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE,false); + #endif } else { - ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYER_1P,false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MULTIPLAYER_1P); + #else + ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYER_1P,false); + #endif } } } @@ -3335,12 +3371,20 @@ void CMinecraftApp::HandleXuiActions(void) if(g_NetworkManager.IsLocalGame()) { app.SetRichPresenceContext(j,CONTEXT_GAME_STATE_BLANK); - ProfileManager.SetCurrentGameActivity(j,CONTEXT_PRESENCE_MULTIPLAYEROFFLINE,false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MULTIPLAYEROFFLINE); + #else + ProfileManager.SetCurrentGameActivity(j,CONTEXT_PRESENCE_MULTIPLAYEROFFLINE,false); + #endif } else { app.SetRichPresenceContext(j,CONTEXT_GAME_STATE_BLANK); - ProfileManager.SetCurrentGameActivity(j,CONTEXT_PRESENCE_MULTIPLAYER,false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MULTIPLAYER); + #else + ProfileManager.SetCurrentGameActivity(j,CONTEXT_PRESENCE_MULTIPLAYER,false); + #endif } TelemetryManager->RecordLevelExit(j, eSen_LevelExitStatus_Exited); } @@ -3351,11 +3395,19 @@ void CMinecraftApp::HandleXuiActions(void) app.SetRichPresenceContext(i,CONTEXT_GAME_STATE_BLANK); if(g_NetworkManager.IsLocalGame()) { - ProfileManager.SetCurrentGameActivity(i,CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE,false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE); + #else + ProfileManager.SetCurrentGameActivity(i,CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE,false); + #endif } else { - ProfileManager.SetCurrentGameActivity(i,CONTEXT_PRESENCE_MULTIPLAYER_1P,false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MULTIPLAYER_1P); + #else + ProfileManager.SetCurrentGameActivity(i,CONTEXT_PRESENCE_MULTIPLAYER_1P,false); + #endif } TelemetryManager->RecordLevelExit(i, eSen_LevelExitStatus_Exited); } diff --git a/Minecraft.Client/Common/Network/GameNetworkManager.cpp b/Minecraft.Client/Common/Network/GameNetworkManager.cpp index bdca0daf..24e63c74 100644 --- a/Minecraft.Client/Common/Network/GameNetworkManager.cpp +++ b/Minecraft.Client/Common/Network/GameNetworkManager.cpp @@ -44,6 +44,7 @@ #ifdef _WINDOWS64 #include "..\..\Windows64\Network\WinsockNetLayer.h" #include "..\..\Windows64\Windows64_Xuid.h" +#include "..\..\Windows64\Windows64_DiscordPresence.h" #endif // Global instance @@ -305,6 +306,7 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame #endif //__PS3__ thread->SetProcessor(CPU_CORE_SERVER); + thread->SetPriority(THREAD_PRIORITY_BELOW_NORMAL); thread->Run(); ServerReadyWait(); @@ -454,13 +456,41 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame app.SetRichPresenceContext(primaryPad,CONTEXT_GAME_STATE_BLANK); if (GetPlayerCount() > 1) // Are we offline or online, and how many players are there { - if (IsLocalGame()) ProfileManager.SetCurrentGameActivity(primaryPad,CONTEXT_PRESENCE_MULTIPLAYEROFFLINE,false); - else ProfileManager.SetCurrentGameActivity(primaryPad,CONTEXT_PRESENCE_MULTIPLAYER,false); + if (IsLocalGame()) + { + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MULTIPLAYEROFFLINE); + #else + ProfileManager.SetCurrentGameActivity(primaryPad,CONTEXT_PRESENCE_MULTIPLAYEROFFLINE,false); + #endif + } + else + { + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MULTIPLAYER); + #else + ProfileManager.SetCurrentGameActivity(primaryPad,CONTEXT_PRESENCE_MULTIPLAYER,false); + #endif + } } else { - if(IsLocalGame()) ProfileManager.SetCurrentGameActivity(primaryPad,CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE,false); - else ProfileManager.SetCurrentGameActivity(primaryPad,CONTEXT_PRESENCE_MULTIPLAYER_1P,false); + if(IsLocalGame()) + { + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE); + #else + ProfileManager.SetCurrentGameActivity(primaryPad,CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE,false); + #endif + } + else + { + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MULTIPLAYER_1P); + #else + ProfileManager.SetCurrentGameActivity(primaryPad,CONTEXT_PRESENCE_MULTIPLAYER_1P,false); + #endif + } } @@ -534,8 +564,22 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame if( ProfileManager.IsSignedIn(idx) && !connection->isClosed() ) { app.SetRichPresenceContext(idx,CONTEXT_GAME_STATE_BLANK); - if (IsLocalGame()) ProfileManager.SetCurrentGameActivity(idx,CONTEXT_PRESENCE_MULTIPLAYEROFFLINE,false); - else ProfileManager.SetCurrentGameActivity(idx,CONTEXT_PRESENCE_MULTIPLAYER,false); + if (IsLocalGame()) + { + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MULTIPLAYEROFFLINE); + #else + ProfileManager.SetCurrentGameActivity(idx,CONTEXT_PRESENCE_MULTIPLAYEROFFLINE,false); + #endif + } + else + { + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MULTIPLAYER); + #else + ProfileManager.SetCurrentGameActivity(idx,CONTEXT_PRESENCE_MULTIPLAYER,false); + #endif + } } else { @@ -1621,13 +1665,41 @@ void CGameNetworkManager::PlayerJoining( INetworkPlayer *pNetworkPlayer ) app.SetRichPresenceContext(iPad,CONTEXT_GAME_STATE_BLANK); if (multiplayer) { - if (localgame) ProfileManager.SetCurrentGameActivity(iPad, CONTEXT_PRESENCE_MULTIPLAYEROFFLINE, false); - else ProfileManager.SetCurrentGameActivity(iPad, CONTEXT_PRESENCE_MULTIPLAYER, false); + if (localgame) + { + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MULTIPLAYEROFFLINE); + #else + ProfileManager.SetCurrentGameActivity(iPad, CONTEXT_PRESENCE_MULTIPLAYEROFFLINE, false); + #endif + } + else + { + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MULTIPLAYER); + #else + ProfileManager.SetCurrentGameActivity(iPad, CONTEXT_PRESENCE_MULTIPLAYER, false); + #endif + } } else { - if (localgame) ProfileManager.SetCurrentGameActivity(iPad, CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE, false); - else ProfileManager.SetCurrentGameActivity(iPad, CONTEXT_PRESENCE_MULTIPLAYER_1P, false); + if (localgame) + { + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE); + #else + ProfileManager.SetCurrentGameActivity(iPad, CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE, false); + #endif + } + else + { + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MULTIPLAYER_1P); + #else + ProfileManager.SetCurrentGameActivity(iPad, CONTEXT_PRESENCE_MULTIPLAYER_1P, false); + #endif + } } } } @@ -1657,7 +1729,11 @@ void CGameNetworkManager::PlayerLeaving( INetworkPlayer *pNetworkPlayer ) { if( pNetworkPlayer->IsLocal() ) { - ProfileManager.SetCurrentGameActivity(pNetworkPlayer->GetUserIndex(),CONTEXT_PRESENCE_IDLE,false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_IDLE); + #else + ProfileManager.SetCurrentGameActivity(pNetworkPlayer->GetUserIndex(),CONTEXT_PRESENCE_IDLE,false); + #endif TelemetryManager->RecordPlayerSessionExit(pNetworkPlayer->GetUserIndex(), app.GetDisconnectReason()); } diff --git a/Minecraft.Client/Common/UI/UIController.cpp b/Minecraft.Client/Common/UI/UIController.cpp index 3c89c453..cc15b65b 100644 --- a/Minecraft.Client/Common/UI/UIController.cpp +++ b/Minecraft.Client/Common/UI/UIController.cpp @@ -668,6 +668,7 @@ void UIController::ReloadSkin() m_reloadSkinThread = new C4JThread(reloadSkinThreadProc, (void*)this, "Reload skin thread"); m_reloadSkinThread->SetProcessor(CPU_CORE_UI_SCENE); + m_updateThread->SetPriority(THREAD_PRIORITY_LOWEST); // Navigate to the timer scene so that we can display something while the loading is happening ui.NavigateToScene(0,eUIScene_Timer,(void *)1,eUILayer_Tooltips,eUIGroup_Fullscreen); diff --git a/Minecraft.Client/Common/UI/UIScene_AnvilMenu.cpp b/Minecraft.Client/Common/UI/UIScene_AnvilMenu.cpp index a3fb0d2d..e9be9a89 100644 --- a/Minecraft.Client/Common/UI/UIScene_AnvilMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_AnvilMenu.cpp @@ -339,20 +339,15 @@ int UIScene_AnvilMenu::KeyboardCompleteCallback(LPVOID lpParam,bool bRes) if (bRes) { + uint16_t pchText[128] = {}; #ifdef _WINDOWS64 - uint16_t pchText[128]; - ZeroMemory(pchText, 128 * sizeof(uint16_t)); Win64_GetKeyboardText(pchText, 128); +#else + InputManager.GetText(pchText); + pClass->setEditNameValue(reinterpret_cast(pchText)); pClass->m_itemName = reinterpret_cast(pchText); pClass->updateItemName(); -#else - uint16_t pchText[128]; - ZeroMemory(pchText, 128 * sizeof(uint16_t) ); - InputManager.GetText(pchText); - pClass->setEditNameValue((wchar_t *)pchText); - pClass->m_itemName = (wchar_t *)pchText; - pClass->updateItemName(); #endif } return 0; diff --git a/Minecraft.Client/Common/UI/UIScene_BeaconMenu.cpp b/Minecraft.Client/Common/UI/UIScene_BeaconMenu.cpp index 64e12373..af668ea3 100644 --- a/Minecraft.Client/Common/UI/UIScene_BeaconMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_BeaconMenu.cpp @@ -41,7 +41,8 @@ UIScene_BeaconMenu::UIScene_BeaconMenu(int iPad, void *_initData, UILayer *paren m_slotListActivatorIcons.addSlots(m_menu->getSize(),4); - //app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_BEACON); + // New + app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_BEACON); delete initData; } diff --git a/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.cpp b/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.cpp index ef72ec16..de125607 100644 --- a/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.cpp @@ -768,8 +768,7 @@ int UIScene_CreateWorldMenu::KeyboardCompleteWorldNameCallback(LPVOID lpParam,bo // 4J HEG - No reason to set value if keyboard was cancelled if (bRes) { - uint16_t pchText[128]; - ZeroMemory(pchText, 128 * sizeof(uint16_t) ); + uint16_t pchText[128] = {}; #ifdef _WINDOWS64 Win64_GetKeyboardText(pchText, 128); #else diff --git a/Minecraft.Client/Common/UI/UIScene_DebugCreateSchematic.cpp b/Minecraft.Client/Common/UI/UIScene_DebugCreateSchematic.cpp index d698b51f..b8b9a387 100644 --- a/Minecraft.Client/Common/UI/UIScene_DebugCreateSchematic.cpp +++ b/Minecraft.Client/Common/UI/UIScene_DebugCreateSchematic.cpp @@ -239,13 +239,10 @@ int UIScene_DebugCreateSchematic::KeyboardCompleteCallback(LPVOID lpParam,bool b { UIScene_DebugCreateSchematic *pClass=static_cast(lpParam); + uint16_t pchText[128] = {}; #ifdef _WINDOWS64 - uint16_t pchText[128]; - ZeroMemory(pchText, 128 * sizeof(uint16_t)); Win64_GetKeyboardText(pchText, 128); #else - uint16_t pchText[128]; - ZeroMemory(pchText, 128 * sizeof(uint16_t) ); InputManager.GetText(pchText); #endif diff --git a/Minecraft.Client/Common/UI/UIScene_DebugSetCamera.cpp b/Minecraft.Client/Common/UI/UIScene_DebugSetCamera.cpp index 51eab5aa..35d5d18d 100644 --- a/Minecraft.Client/Common/UI/UIScene_DebugSetCamera.cpp +++ b/Minecraft.Client/Common/UI/UIScene_DebugSetCamera.cpp @@ -193,12 +193,10 @@ void UIScene_DebugSetCamera::handleCheckboxToggled(F64 controlId, bool selected) int UIScene_DebugSetCamera::KeyboardCompleteCallback(LPVOID lpParam,bool bRes) { UIScene_DebugSetCamera *pClass=static_cast(lpParam); - uint16_t pchText[2048]; - ZeroMemory(pchText, 2048 * sizeof(uint16_t)); + uint16_t pchText[2048] = {}; #ifdef _WINDOWS64 Win64_GetKeyboardText(pchText, 2048); #else ->>>>>>> origin/main InputManager.GetText(pchText); #endif diff --git a/Minecraft.Client/Common/UI/UIScene_EndPoem.cpp b/Minecraft.Client/Common/UI/UIScene_EndPoem.cpp index ead86c3d..62c2e92e 100644 --- a/Minecraft.Client/Common/UI/UIScene_EndPoem.cpp +++ b/Minecraft.Client/Common/UI/UIScene_EndPoem.cpp @@ -108,6 +108,9 @@ UIScene_EndPoem::UIScene_EndPoem(int iPad, void *initData, UILayer *parentLayer) #endif m_requestedLabel = 0; + + // New + app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_END_POEM); } wstring UIScene_EndPoem::getMoviePath() diff --git a/Minecraft.Client/Common/UI/UIScene_FireworksMenu.cpp b/Minecraft.Client/Common/UI/UIScene_FireworksMenu.cpp index b33e086a..90bf1fef 100644 --- a/Minecraft.Client/Common/UI/UIScene_FireworksMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_FireworksMenu.cpp @@ -31,6 +31,9 @@ UIScene_FireworksMenu::UIScene_FireworksMenu(int iPad, void *_initData, UILayer m_slotList3x3.addSlots(FireworksMenu::CRAFT_SLOT_START, 9); ShowLargeCraftingGrid(true); + // New + app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_FIREWORKS); + delete initData; } diff --git a/Minecraft.Client/Common/UI/UIScene_FullscreenProgress.cpp b/Minecraft.Client/Common/UI/UIScene_FullscreenProgress.cpp index 6a4ea096..e39869a1 100644 --- a/Minecraft.Client/Common/UI/UIScene_FullscreenProgress.cpp +++ b/Minecraft.Client/Common/UI/UIScene_FullscreenProgress.cpp @@ -61,6 +61,7 @@ UIScene_FullscreenProgress::UIScene_FullscreenProgress(int iPad, void *initData, thread = new C4JThread(params->func, params->lpParam, "FullscreenProgress"); thread->SetProcessor(CPU_CORE_UI_SCENE); // TODO 4J Stu - Make sure this is a good thread/core to use + thread->SetPriority(THREAD_PRIORITY_LOWEST); m_threadCompleted = false; thread->Run(); diff --git a/Minecraft.Client/Common/UI/UIScene_FurnaceMenu.cpp b/Minecraft.Client/Common/UI/UIScene_FurnaceMenu.cpp index 9d90804f..3ee42ce0 100644 --- a/Minecraft.Client/Common/UI/UIScene_FurnaceMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_FurnaceMenu.cpp @@ -36,6 +36,7 @@ UIScene_FurnaceMenu::UIScene_FurnaceMenu(int iPad, void *_initData, UILayer *par m_slotListIngredient.addSlots(FurnaceMenu::INGREDIENT_SLOT, 1); m_slotListResult.addSlots(FurnaceMenu::RESULT_SLOT, 1); + // New app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_FURNACE); delete initData; diff --git a/Minecraft.Client/Common/UI/UIScene_HopperMenu.cpp b/Minecraft.Client/Common/UI/UIScene_HopperMenu.cpp index 8c657c97..b2996134 100644 --- a/Minecraft.Client/Common/UI/UIScene_HopperMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_HopperMenu.cpp @@ -29,6 +29,9 @@ UIScene_HopperMenu::UIScene_HopperMenu(int iPad, void *_initData, UILayer *paren m_slotListTrap.addSlots(0, 9); + // New + app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_HOPPER); + delete initData; } diff --git a/Minecraft.Client/Common/UI/UIScene_HorseInventoryMenu.cpp b/Minecraft.Client/Common/UI/UIScene_HorseInventoryMenu.cpp index c062df4e..82a28b7a 100644 --- a/Minecraft.Client/Common/UI/UIScene_HorseInventoryMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_HorseInventoryMenu.cpp @@ -55,7 +55,8 @@ UIScene_HorseInventoryMenu::UIScene_HorseInventoryMenu(int iPad, void *_initData setIgnoreInput(false); - //app.SetRichPresenceContext(iPad, CONTEXT_GAME_STATE_HORSE); + // New + app.SetRichPresenceContext(iPad, CONTEXT_GAME_STATE_HORSE); } wstring UIScene_HorseInventoryMenu::getMoviePath() diff --git a/Minecraft.Client/Common/UI/UIScene_JoinMenu.cpp b/Minecraft.Client/Common/UI/UIScene_JoinMenu.cpp index 5b83ea7c..122290b4 100644 --- a/Minecraft.Client/Common/UI/UIScene_JoinMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_JoinMenu.cpp @@ -775,12 +775,11 @@ int UIScene_JoinMenu::EditServerKeyboardCallback(LPVOID lpParam, bool bRes) return 0; } - uint16_t ui16Text[256]; - ZeroMemory(ui16Text, sizeof(ui16Text)); - Win64_GetKeyboardText(ui16Text, 256); + uint16_t ui16Text[128] = {}; + Win64_GetKeyboardText(ui16Text, 128); - wchar_t wBuf[256] = {}; - for (int k = 0; k < 255 && ui16Text[k]; k++) + wchar_t wBuf[128] = {}; + for (int k = 0; k < 127 && ui16Text[k]; k++) wBuf[k] = (wchar_t)ui16Text[k]; if (wBuf[0] == 0) diff --git a/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp index 1832e40c..8d50cbe2 100644 --- a/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp @@ -554,18 +554,15 @@ int UIScene_LaunchMoreOptionsMenu::KeyboardCompleteSeedCallback(LPVOID lpParam,b if (bRes) { #ifdef _WINDOWS64 - uint16_t pchText[128]; - ZeroMemory(pchText, 128 * sizeof(uint16_t)); + uint16_t pchText[128] = {}; Win64_GetKeyboardText(pchText, 128); pClass->m_editSeed.setLabel(reinterpret_cast(pchText)); pClass->m_params->seed = static_cast(reinterpret_cast(pchText)); #else #ifdef __PSVITA__ - uint16_t pchText[2048]; - ZeroMemory(pchText, 2048 * sizeof(uint16_t) ); + uint16_t pchText[2048] = {}; #else - uint16_t pchText[128]; - ZeroMemory(pchText, 128 * sizeof(uint16_t) ); + uint16_t pchText[128] = {}; #endif InputManager.GetText(pchText); pClass->m_editSeed.setLabel((wchar_t *)pchText); diff --git a/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.cpp b/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.cpp index 08bfaf95..8596a7f8 100644 --- a/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.cpp @@ -1402,8 +1402,7 @@ int UIScene_LoadOrJoinMenu::KeyboardCompleteWorldNameCallback(LPVOID lpParam,boo pClass->m_bIgnoreInput=false; if (bRes) { - uint16_t ui16Text[128]; - ZeroMemory(ui16Text, 128 * sizeof(uint16_t) ); + uint16_t ui16Text[128] = {}; #ifdef _WINDOWS64 Win64_GetKeyboardText(ui16Text, 128); #else @@ -4094,12 +4093,12 @@ int UIScene_LoadOrJoinMenu::AddServerKeyboardCallback(LPVOID lpParam, bool bRes) return 0; } - uint16_t ui16Text[256]; - ZeroMemory(ui16Text, sizeof(ui16Text)); - Win64_GetKeyboardText(ui16Text, 256); + uint16_t ui16Text[128] = {}; - wchar_t wBuf[256] = {}; - for (int k = 0; k < 255 && ui16Text[k]; k++) + Win64_GetKeyboardText(ui16Text, 128); + + wchar_t wBuf[128] = {}; + for (int k = 0; k < 127 && ui16Text[k]; k++) wBuf[k] = static_cast(ui16Text[k]); if (wBuf[0] == 0) diff --git a/Minecraft.Client/Common/UI/UIScene_MainMenu.cpp b/Minecraft.Client/Common/UI/UIScene_MainMenu.cpp index 93f1edf1..a2fc43e3 100644 --- a/Minecraft.Client/Common/UI/UIScene_MainMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_MainMenu.cpp @@ -10,6 +10,10 @@ #include #endif +#ifdef _WINDOWS64 +#include "..\..\Windows64\Windows64_DiscordPresence.h" +#endif + Random *UIScene_MainMenu::random = new Random(); EUIScene UIScene_MainMenu::eNavigateWhenReady = static_cast(-1); @@ -166,7 +170,11 @@ void UIScene_MainMenu::handleGainFocus(bool navBack) // For returning to menus after exiting a game. if (ProfileManager.IsSignedIn(iPad) ) { - ProfileManager.SetCurrentGameActivity(iPad, CONTEXT_PRESENCE_MENUS, false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MENUS); + #else + ProfileManager.SetCurrentGameActivity(iPad, CONTEXT_PRESENCE_MENUS, false); + #endif } } } @@ -540,7 +548,11 @@ int UIScene_MainMenu::MustSignInReturned(void *pParam, int iPad, C4JStorage::EMe // if the user is valid, we should set the presence if(ProfileManager.IsSignedIn(i)) { - ProfileManager.SetCurrentGameActivity(i, CONTEXT_PRESENCE_MENUS, false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MENUS); + #else + ProfileManager.SetCurrentGameActivity(i, CONTEXT_PRESENCE_MENUS, false); + #endif } } } @@ -648,8 +660,11 @@ int UIScene_MainMenu::HelpAndOptions_SignInReturned(void *pParam,bool bContinue, if(bContinue) { // 4J-JEV: Don't we only need to update rich-presence if the sign-in status changes. - ProfileManager.SetCurrentGameActivity(iPad, CONTEXT_PRESENCE_MENUS, false); - + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MENUS); + #else + ProfileManager.SetCurrentGameActivity(iPad, CONTEXT_PRESENCE_MENUS, false); + #endif #if TO_BE_IMPLEMENTED if(app.GetTMSDLCInfoRead()) #endif @@ -690,7 +705,11 @@ int UIScene_MainMenu::HelpAndOptions_SignInReturned(void *pParam,bool bContinue, // if the user is valid, we should set the presence if(ProfileManager.IsSignedIn(i)) { - ProfileManager.SetCurrentGameActivity(i,CONTEXT_PRESENCE_MENUS,false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MENUS); + #else + ProfileManager.SetCurrentGameActivity(i,CONTEXT_PRESENCE_MENUS,false); + #endif } } } @@ -719,7 +738,12 @@ int UIScene_MainMenu::CreateLoad_SignInReturned(void *pParam, bool bContinue, in if(bContinue) { // 4J-JEV: We only need to update rich-presence if the sign-in status changes. - ProfileManager.SetCurrentGameActivity(iPad, CONTEXT_PRESENCE_MENUS, false); + + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MENUS); + #else + ProfileManager.SetCurrentGameActivity(iPad, CONTEXT_PRESENCE_MENUS, false); + #endif UINT uiIDA[1] = { IDS_OK }; @@ -902,7 +926,11 @@ int UIScene_MainMenu::CreateLoad_SignInReturned(void *pParam, bool bContinue, in // if the user is valid, we should set the presence if(ProfileManager.IsSignedIn(i)) { - ProfileManager.SetCurrentGameActivity(i,CONTEXT_PRESENCE_MENUS,false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MENUS); + #else + ProfileManager.SetCurrentGameActivity(i, CONTEXT_PRESENCE_MENUS, false); + #endif } } @@ -921,7 +949,11 @@ int UIScene_MainMenu::Leaderboards_SignInReturned(void *pParam,bool bContinue,in if(bContinue) { // 4J-JEV: We only need to update rich-presence if the sign-in status changes. - ProfileManager.SetCurrentGameActivity(iPad, CONTEXT_PRESENCE_MENUS, false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MENUS); + #else + ProfileManager.SetCurrentGameActivity(iPad, CONTEXT_PRESENCE_MENUS, false); + #endif UINT uiIDA[1] = { IDS_OK }; @@ -972,7 +1004,11 @@ int UIScene_MainMenu::Leaderboards_SignInReturned(void *pParam,bool bContinue,in // if the user is valid, we should set the presence if(ProfileManager.IsSignedIn(i)) { - ProfileManager.SetCurrentGameActivity(i,CONTEXT_PRESENCE_MENUS,false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MENUS); + #else + ProfileManager.SetCurrentGameActivity(i, CONTEXT_PRESENCE_MENUS, false); + #endif } } @@ -992,7 +1028,11 @@ int UIScene_MainMenu::Achievements_SignInReturned(void *pParam,bool bContinue,in { pClass->m_bIgnorePress=false; // 4J-JEV: We only need to update rich-presence if the sign-in status changes. - ProfileManager.SetCurrentGameActivity(iPad, CONTEXT_PRESENCE_MENUS, false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MENUS); + #else + ProfileManager.SetCurrentGameActivity(iPad, CONTEXT_PRESENCE_MENUS, false); + #endif XShowAchievementsUI( ProfileManager.GetPrimaryPad() ); } @@ -1006,7 +1046,11 @@ int UIScene_MainMenu::Achievements_SignInReturned(void *pParam,bool bContinue,in // if the user is valid, we should set the presence if(ProfileManager.IsSignedIn(i)) { - ProfileManager.SetCurrentGameActivity(i,CONTEXT_PRESENCE_MENUS,false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MENUS); + #else + ProfileManager.SetCurrentGameActivity(i, CONTEXT_PRESENCE_MENUS, false); + #endif } } @@ -1025,7 +1069,11 @@ int UIScene_MainMenu::UnlockFullGame_SignInReturned(void *pParam,bool bContinue, if (bContinue) { // 4J-JEV: We only need to update rich-presence if the sign-in status changes. - ProfileManager.SetCurrentGameActivity(iPad, CONTEXT_PRESENCE_MENUS, false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MENUS); + #else + ProfileManager.SetCurrentGameActivity(iPad, CONTEXT_PRESENCE_MENUS, false); + #endif pClass->RunUnlockOrDLC(iPad); } @@ -1039,7 +1087,11 @@ int UIScene_MainMenu::UnlockFullGame_SignInReturned(void *pParam,bool bContinue, // if the user is valid, we should set the presence if(ProfileManager.IsSignedIn(i)) { - ProfileManager.SetCurrentGameActivity(i,CONTEXT_PRESENCE_MENUS,false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MENUS); + #else + ProfileManager.SetCurrentGameActivity(i, CONTEXT_PRESENCE_MENUS, false); + #endif } } diff --git a/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.cpp index 5ef783d3..0d9c8ea4 100644 --- a/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.cpp @@ -55,6 +55,9 @@ UIScene_SignEntryMenu::UIScene_SignEntryMenu(int iPad, void *_initData, UILayer } parentLayer->addComponent(iPad,eUIComponent_MenuBackground); + + // New + app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_SIGN); } UIScene_SignEntryMenu::~UIScene_SignEntryMenu() @@ -313,17 +316,13 @@ int UIScene_SignEntryMenu::KeyboardCompleteCallback(LPVOID lpParam,bool bRes) pClass->m_bIgnoreInput = false; if (bRes) { + uint16_t pchText[128] = {}; #ifdef _WINDOWS64 - uint16_t pchText[128]; - ZeroMemory(pchText, 128 * sizeof(uint16_t)); Win64_GetKeyboardText(pchText, 128); - pClass->m_textInputLines[pClass->m_iEditingLine].setLabel(reinterpret_cast(pchText)); #else - uint16_t pchText[128]; - ZeroMemory(pchText, 128 * sizeof(uint16_t) ); InputManager.GetText(pchText); - pClass->m_textInputLines[pClass->m_iEditingLine].setLabel((wchar_t *)pchText); #endif + pClass->m_textInputLines[pClass->m_iEditingLine].setLabel(reinterpret_cast(pchText)); } return 0; } diff --git a/Minecraft.Client/GameRenderer.cpp b/Minecraft.Client/GameRenderer.cpp index 6cf60a24..42d17cd7 100644 --- a/Minecraft.Client/GameRenderer.cpp +++ b/Minecraft.Client/GameRenderer.cpp @@ -175,6 +175,7 @@ GameRenderer::GameRenderer(Minecraft *mc) m_updateThread->SetPriority(THREAD_PRIORITY_ABOVE_NORMAL); #endif// __PS3__ m_updateThread->SetProcessor(CPU_CORE_CHUNK_UPDATE); + m_updateThread->SetPriority(THREAD_PRIORITY_HIGHEST); m_updateThread->Run(); #endif } diff --git a/Minecraft.Client/LocalPlayer.cpp b/Minecraft.Client/LocalPlayer.cpp index 00b1761b..0d34b496 100644 --- a/Minecraft.Client/LocalPlayer.cpp +++ b/Minecraft.Client/LocalPlayer.cpp @@ -56,6 +56,10 @@ #ifndef _DURANGO #include "..\Minecraft.World\CommonStats.h" #endif + +#ifdef _WINDOWS64 +#include "Windows64\Windows64_DiscordPresence.h" +#endif extern ConsoleUIController ui; @@ -507,7 +511,11 @@ void LocalPlayer::aiStep() // Check if the player is idle and the rich presence needs updated if( !m_bIsIdle && InputManager.GetIdleSeconds( m_iPad ) > PLAYER_IDLE_TIME ) { - ProfileManager.SetCurrentGameActivity(m_iPad,CONTEXT_PRESENCE_IDLE,false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_IDLE); + #else + ProfileManager.SetCurrentGameActivity(m_iPad,CONTEXT_PRESENCE_IDLE,false); + #endif m_bIsIdle = true; } else if ( m_bIsIdle && InputManager.GetIdleSeconds( m_iPad ) < PLAYER_IDLE_TIME ) @@ -518,22 +526,38 @@ void LocalPlayer::aiStep() // only do it for this player here - each player will run this code if(g_NetworkManager.IsLocalGame()) { - ProfileManager.SetCurrentGameActivity(m_iPad,CONTEXT_PRESENCE_MULTIPLAYEROFFLINE,false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MULTIPLAYEROFFLINE); + #else + ProfileManager.SetCurrentGameActivity(m_iPad,CONTEXT_PRESENCE_MULTIPLAYEROFFLINE,false); + #endif } else { - ProfileManager.SetCurrentGameActivity(m_iPad,CONTEXT_PRESENCE_MULTIPLAYER,false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MULTIPLAYER); + #else + ProfileManager.SetCurrentGameActivity(m_iPad,CONTEXT_PRESENCE_MULTIPLAYER,false); + #endif } } else { if(g_NetworkManager.IsLocalGame()) { - ProfileManager.SetCurrentGameActivity(m_iPad,CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE,false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE); + #else + ProfileManager.SetCurrentGameActivity(m_iPad,CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE,false); + #endif } else { - ProfileManager.SetCurrentGameActivity(m_iPad,CONTEXT_PRESENCE_MULTIPLAYER_1P,false); + #ifdef _WINDOWS64 + g_DiscordPresence.SetCurrentGameActivity(CONTEXT_PRESENCE_MULTIPLAYER_1P); + #else + ProfileManager.SetCurrentGameActivity(m_iPad,CONTEXT_PRESENCE_MULTIPLAYER_1P,false); + #endif } } updateRichPresence(); @@ -1637,37 +1661,25 @@ void LocalPlayer::updateRichPresence() { shared_ptr selectedItem = inventory->getSelected(); if(selectedItem != nullptr && selectedItem->id == Item::fishingRod_Id) - { app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_FISHING); - } else if(selectedItem != nullptr && selectedItem->id == Item::map_Id) - { app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_MAP); - } else if ( (riding != nullptr) && riding->instanceof(eTYPE_MINECART) ) - { app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_RIDING_MINECART); - } else if ( (riding != nullptr) && riding->instanceof(eTYPE_BOAT) ) - { app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_BOATING); - } else if ( (riding != nullptr) && riding->instanceof(eTYPE_PIG) ) - { app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_RIDING_PIG); - } + else if ( (riding != nullptr) && riding->instanceof(eTYPE_HORSE) ) + app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_RIDING_HORSE); else if( this->dimension == -1 ) - { app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_NETHER); - } + else if( this->dimension == 1 ) + app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_END); else if( minecraft->soundEngine->GetIsPlayingStreamingCDMusic() ) - { app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_CD); - } else - { app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_BLANK); - } } } diff --git a/Minecraft.Client/ServerLevel.cpp b/Minecraft.Client/ServerLevel.cpp index 7ccd8122..452ba34b 100644 --- a/Minecraft.Client/ServerLevel.cpp +++ b/Minecraft.Client/ServerLevel.cpp @@ -65,6 +65,7 @@ void ServerLevel::staticCtor() m_updateThread = new C4JThread(runUpdate, nullptr, "Tile update"); m_updateThread->SetProcessor(CPU_CORE_TILE_UPDATE); + m_updateThread->SetPriority(THREAD_PRIORITY_ABOVE_NORMAL); // #ifdef __ORBIS__ m_updateThread->SetPriority(THREAD_PRIORITY_BELOW_NORMAL); // On Orbis, this core is also used for Matching 2, and that priority of that seems to be always at default no matter what we set it to. Prioritise this below Matching 2. #endif diff --git a/Minecraft.World/Connection.cpp b/Minecraft.World/Connection.cpp index d4450266..1fd2235f 100644 --- a/Minecraft.World/Connection.cpp +++ b/Minecraft.World/Connection.cpp @@ -115,6 +115,8 @@ Connection::Connection(Socket *socket, const wstring& id, PacketListener *packet writeThread = new C4JThread(runWrite, this, writeThreadName, WRITE_STACK_SIZE); readThread->SetProcessor(CPU_CORE_CONNECTIONS); writeThread->SetProcessor(CPU_CORE_CONNECTIONS ); + writeThread->SetPriority(THREAD_PRIORITY_BELOW_NORMAL); // + readThread->SetPriority(THREAD_PRIORITY_BELOW_NORMAL); // #ifdef __ORBIS__ readThread->SetPriority(THREAD_PRIORITY_BELOW_NORMAL); // On Orbis, this core is also used for Matching 2, and that priority of that seems to be always at default no matter what we set it to. Prioritise this below Matching 2. writeThread->SetPriority(THREAD_PRIORITY_BELOW_NORMAL); // On Orbis, this core is also used for Matching 2, and that priority of that seems to be always at default no matter what we set it to. Prioritise this below Matching 2.