diff --git a/Minecraft.Client/Minecraft.cpp b/Minecraft.Client/Minecraft.cpp index 7ae206cf9..463eb26ad 100644 --- a/Minecraft.Client/Minecraft.cpp +++ b/Minecraft.Client/Minecraft.cpp @@ -52,7 +52,6 @@ #include "..\Minecraft.World\net.minecraft.world.level.dimension.h" #include "..\Minecraft.World\net.minecraft.world.item.h" #include "..\Minecraft.World\Minecraft.World.h" -#include "Windows64\Windows64_Xuid.h" #include "ClientConnection.h" #include "..\Minecraft.World\HellRandomLevelSource.h" #include "..\Minecraft.World\net.minecraft.world.entity.animal.h" @@ -80,7 +79,7 @@ //#define DEBUG_RENDER_SHOWS_PACKETS 1 //#define SPLITSCREEN_TEST -// If not disabled, this creates an event queue on a seperate thread so that the Level::tick calls can be offloaded +// If not disabled, this creates an event queue on a seperate thread so that the Level::tick calls can be offloaded // from the main thread, and have longer to run, since it's called at 20Hz instead of 60 #define DISABLE_LEVELTICK_THREAD @@ -97,7 +96,7 @@ TOUCHSCREENRECT QuickSelectRect[3]= { { 560, 890, 1360, 980 }, { 450, 840, 1449, 960 }, - { 320, 840, 1600, 970 }, + { 320, 840, 1600, 970 }, }; int QuickSelectBoxWidth[3]= @@ -742,7 +741,7 @@ void Minecraft::run() while (System::currentTimeMillis() >= lastTime + 1000) { - fpsString = std::to_wstring(frames) + L" fps, " + std::to_wstring(Chunk::updates) + L" chunk updates"; + fpsString = _toString(frames) + L" fps, " + _toString(Chunk::updates) + L" chunk updates"; Chunk::updates = 0; lastTime += 1000; frames = 0; @@ -1039,19 +1038,6 @@ shared_ptr Minecraft::createExtraLocalPlayer(int idx, co PlayerUID playerXUIDOnline = INVALID_XUID; ProfileManager.GetXUID(idx,&playerXUIDOffline,false); ProfileManager.GetXUID(idx,&playerXUIDOnline,true); -#ifdef _WINDOWS64 - // Compatibility rule for Win64 id migration - // host keeps legacy host XUID, non-host uses persistent uid.dat XUID. - INetworkPlayer *localNetworkPlayer = g_NetworkManager.GetLocalPlayerByUserIndex(idx); - if(localNetworkPlayer != NULL && localNetworkPlayer->IsHost()) - { - playerXUIDOffline = Win64Xuid::GetLegacyEmbeddedHostXuid(); - } - else - { - playerXUIDOffline = Win64Xuid::ResolvePersistentXuid(); - } -#endif localplayers[idx]->setXuid(playerXUIDOffline); localplayers[idx]->setOnlineXuid(playerXUIDOnline); localplayers[idx]->setIsGuest(ProfileManager.IsGuest(idx)); @@ -1300,7 +1286,7 @@ void Minecraft::run_middle() if( pDLCPack ) { if(!pDLCPack->hasPurchasedFile( DLCManager::e_DLCType_Texture, L"" )) - { + { bTrialTexturepack=true; } } @@ -1422,7 +1408,7 @@ void Minecraft::run_middle() { delete m_pPsPlusUpsell; m_pPsPlusUpsell = NULL; - + if ( ProfileManager.HasPlayStationPlus(i) ) { app.DebugPrintf(" Player_%i is now authorised for PsPlus.\n", i); @@ -1593,7 +1579,10 @@ void Minecraft::run_middle() s_prevXButtons[i] = xCurButtons; } bool startJustPressed = s_startPressLatch[i] > 0; - bool tryJoin = !pause && !ui.IsIgnorePlayerJoinMenuDisplayed(ProfileManager.GetPrimaryPad()) && g_NetworkManager.SessionHasSpace() && xCurButtons != 0; + // Use (xCurButtons != 0 || startJustPressed) so that a quick Start tap that first + // triggers ShowPressStart (PressStartPlaying was false) can still complete the join + // on subsequent frames while the latch is active, even after the button is released. + bool tryJoin = !pause && !ui.IsIgnorePlayerJoinMenuDisplayed(ProfileManager.GetPrimaryPad()) && g_NetworkManager.SessionHasSpace() && (xCurButtons != 0 || startJustPressed); #else bool tryJoin = !pause && !ui.IsIgnorePlayerJoinMenuDisplayed(ProfileManager.GetPrimaryPad()) && g_NetworkManager.SessionHasSpace() && RenderManager.IsHiDef() && InputManager.ButtonPressed(i); #endif @@ -1634,13 +1623,14 @@ void Minecraft::run_middle() // are they signed in? #ifdef _WINDOWS64 - if(ProfileManager.IsSignedIn(i) || (g_NetworkManager.IsLocalGame() && InputManager.IsPadConnected(i))) + // On Windows64 any physically-connected controller can join without a profile sign-in. + if(ProfileManager.IsSignedIn(i) || InputManager.IsPadConnected(i)) #else if(ProfileManager.IsSignedIn(i)) #endif { // if this is a local game, then the player just needs to be signed in - if( g_NetworkManager.IsLocalGame() || (ProfileManager.IsSignedInLive(i) && ProfileManager.AllowedToPlayMultiplayer(i) ) ) + if( g_NetworkManager.IsLocalGame() || InputManager.IsPadConnected(i) || (ProfileManager.IsSignedInLive(i) && ProfileManager.AllowedToPlayMultiplayer(i) ) ) { #ifdef __ORBIS__ bool contentRestricted = false; @@ -2048,7 +2038,7 @@ void Minecraft::run_middle() while (System::nanoTime() >= lastTime + 1000000000) { MemSect(31); - fpsString = std::to_wstring(frames) + L" fps, " + std::to_wstring(Chunk::updates) + L" chunk updates"; + fpsString = _toString(frames) + L" fps, " + _toString(Chunk::updates) + L" chunk updates"; MemSect(0); Chunk::updates = 0; lastTime += 1000000000; @@ -2245,7 +2235,7 @@ void Minecraft::levelTickThreadInitFunc() { AABB::CreateNewThreadStorage(); Vec3::CreateNewThreadStorage(); - IntCache::CreateNewThreadStorage(); + IntCache::CreateNewThreadStorage(); Compression::UseDefaultThreadStorage(); } @@ -2875,10 +2865,10 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) shared_ptr heldItem = nullptr; if (player->inventory->IsHeldItem()) { - heldItem = player->inventory->getSelected(); + heldItem = player->inventory->getSelected(); } int heldItemId = heldItem != NULL ? heldItem->getItem()->id : -1; - + switch(entityType) { case eTYPE_CHICKEN: @@ -2920,7 +2910,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) case eTYPE_COW: { if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT; - + shared_ptr animal = dynamic_pointer_cast(hitResult->entity); if (animal->isLeashed() && animal->getLeashHolder() == player) @@ -2984,7 +2974,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) *piUse=IDS_TOOLTIPS_MILK; break; case Item::shears_Id: - { + { if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT; if(!animal->isBaby()) *piUse=IDS_TOOLTIPS_SHEAR; } @@ -3012,10 +3002,10 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) *piAction = IDS_TOOLTIPS_MINE; *piUse = IDS_TOOLTIPS_RIDE; // are we in the minecart already? - 4J-JEV: Doesn't matter anymore. break; - + case eTYPE_MINECART_FURNACE: *piAction = IDS_TOOLTIPS_MINE; - + // if you have coal, it'll go. Is there an object in hand? if (heldItemId == Item::coal_Id) *piUse=IDS_TOOLTIPS_USE; break; @@ -3096,7 +3086,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT; shared_ptr pig = dynamic_pointer_cast(hitResult->entity); - + if (pig->isLeashed() && pig->getLeashHolder() == player) { *piUse=IDS_TOOLTIPS_UNLEASH; @@ -3239,7 +3229,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) shared_ptr ocelot = dynamic_pointer_cast(hitResult->entity); if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT; - + if (ocelot->isLeashed() && ocelot->getLeashHolder() == player) { *piUse = IDS_TOOLTIPS_UNLEASH; @@ -3268,7 +3258,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) } else { - *piUse=IDS_TOOLTIPS_FEED; + *piUse=IDS_TOOLTIPS_FEED; } } @@ -3291,7 +3281,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) } } break; - + case eTYPE_PLAYER: { // Fix for #58576 - TU6: Content: Gameplay: Hit button prompt is available when attacking a host who has "Invisible" option turned on @@ -3357,9 +3347,9 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) case eTYPE_HORSE: { shared_ptr horse = dynamic_pointer_cast(hitResult->entity); - + bool heldItemIsFood = false, heldItemIsLove = false, heldItemIsArmour = false; - + switch( heldItemId ) { case Item::wheat_Id: @@ -3414,7 +3404,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) *piUse = IDS_TOOLTIPS_FEED; } } - else if ( player->isSneaking() + else if ( player->isSneaking() || (heldItemId == Item::saddle_Id) || (horse->canWearArmor() && heldItemIsArmour) ) @@ -3423,7 +3413,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) if (*piUse == -1) *piUse = IDS_TOOLTIPS_OPEN; } else if ( horse->canWearBags() - && !horse->isChestedHorse() + && !horse->isChestedHorse() && (heldItemId == Tile::chest_Id) ) { // 4j - Attach saddle-bags (chest) to donkey or mule. @@ -3445,7 +3435,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) // 4j - Ride tamed horse. *piUse = IDS_TOOLTIPS_MOUNT; } - + if (player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT; } break; @@ -3485,7 +3475,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) } } *piAction=IDS_TOOLTIPS_HIT; - break; + break; } break; } @@ -3544,14 +3534,11 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) } #ifdef _WINDOWS64 - bool actionPressed = InputManager.ButtonPressed(iPad, MINECRAFT_ACTION_ACTION) || (iPad == 0 && g_KBMInput.IsKBMActive() && g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_LEFT)); bool actionHeld = InputManager.ButtonDown(iPad, MINECRAFT_ACTION_ACTION) || (iPad == 0 && g_KBMInput.IsKBMActive() && g_KBMInput.IsMouseButtonDown(KeyboardMouseInput::MOUSE_LEFT)); #else - bool actionPressed = InputManager.ButtonPressed(iPad, MINECRAFT_ACTION_ACTION); bool actionHeld = InputManager.ButtonDown(iPad, MINECRAFT_ACTION_ACTION); #endif - - if (actionPressed) + if (actionHeld && ticks - player->lastClickTick[0] >= timer->ticksPerSecond / 4) { //printf("MINECRAFT_ACTION_ACTION ButtonDown"); player->handleMouseClick(0); @@ -3683,7 +3670,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) player->abilities.debugflying = !player->abilities.debugflying; player->abilities.flying = !player->abilities.flying; } -#endif // PSVITA +#endif // PSVITA } #endif @@ -3760,7 +3747,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) } __uint64 ullButtonsPressed=player->ullButtonsPressed; - + bool selected = false; #ifdef __PSVITA__ // 4J-PB - use the touchscreen for quickselect @@ -3785,7 +3772,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) shared_ptr selectedItem = player->getSelectedItem(); // Dropping items happens over network, so if we only have one then assume that we dropped it and should hide the item int iCount=0; - + if(selectedItem != NULL) iCount=selectedItem->GetCount(); if(selectedItem != NULL && !( (player->ullButtonsPressed&(1LL<GetCount() == 1)) { @@ -4094,7 +4081,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) } #ifdef __PS3__ -// while(!g_tickLevelQueue.empty()) +// while(!g_tickLevelQueue.empty()) // { // Level* pLevel = g_tickLevelQueue.front(); // g_tickLevelQueue.pop(); @@ -4312,19 +4299,6 @@ void Minecraft::setLevel(MultiPlayerLevel *level, int message /*=-1*/, shared_pt // player doesn't have an online UID, set it from the player name playerXUIDOnline.setForAdhoc(); } -#endif -#ifdef _WINDOWS64 - // On Windows, the implementation has been changed to use a per-client pseudo XUID based on `uid.dat`. - // To maintain player data compatibility with existing worlds, the world host (the first player) will use the previous embedded pseudo XUID. - INetworkPlayer *localNetworkPlayer = g_NetworkManager.GetLocalPlayerByUserIndex(iPrimaryPlayer); - if(localNetworkPlayer != NULL && localNetworkPlayer->IsHost()) - { - playerXUIDOffline = Win64Xuid::GetLegacyEmbeddedHostXuid(); - } - else - { - playerXUIDOffline = Win64Xuid::ResolvePersistentXuid(); - } #endif player->setXuid(playerXUIDOffline); player->setOnlineXuid(playerXUIDOnline); @@ -4335,7 +4309,7 @@ void Minecraft::setLevel(MultiPlayerLevel *level, int message /*=-1*/, shared_pt player->resetPos(); gameMode->initPlayer(player); - + player->SetXboxPad(iPrimaryPlayer); for(int i=0;igatherStats1(); - return L"Time to autosave: " + std::to_wstring( app.SecondsToAutosave() ) + L"s"; + return L"Time to autosave: " + _toString( app.SecondsToAutosave() ) + L"s"; } wstring Minecraft::gatherStats2() @@ -4508,18 +4482,6 @@ void Minecraft::respawnPlayer(int iPad, int dimension, int newEntityId) PlayerUID playerXUIDOnline = INVALID_XUID; ProfileManager.GetXUID(iTempPad,&playerXUIDOffline,false); ProfileManager.GetXUID(iTempPad,&playerXUIDOnline,true); -#ifdef _WINDOWS64 - // Same compatibility rule as create/init paths. - INetworkPlayer *localNetworkPlayer = g_NetworkManager.GetLocalPlayerByUserIndex(iTempPad); - if(localNetworkPlayer != NULL && localNetworkPlayer->IsHost()) - { - playerXUIDOffline = Win64Xuid::GetLegacyEmbeddedHostXuid(); - } - else - { - playerXUIDOffline = Win64Xuid::ResolvePersistentXuid(); - } -#endif player->setXuid(playerXUIDOffline); player->setOnlineXuid(playerXUIDOnline); player->setIsGuest( ProfileManager.IsGuest(iTempPad) ); @@ -4652,7 +4614,7 @@ void Minecraft::startAndConnectTo(const wstring& name, const wstring& sid, const } else { - minecraft->user = new User(L"Player" + std::to_wstring(System::currentTimeMillis() % 1000), L""); + minecraft->user = new User(L"Player" + _toString(System::currentTimeMillis() % 1000), L""); } } //else @@ -4733,7 +4695,7 @@ void Minecraft::main() } app.DebugPrintf("\n\n\n\n\n"); - + for(unsigned int i = 0; i < 256; ++i) { if(Tile::tiles[i] != NULL) @@ -4747,7 +4709,7 @@ void Minecraft::main() // 4J-PB - Can't call this for the first 5 seconds of a game - MS rule //if (ProfileManager.IsFullVersion()) { - name = L"Player" + std::to_wstring(System::currentTimeMillis() % 1000); + name = L"Player" + _toString<__int64>(System::currentTimeMillis() % 1000); sessionId = L"-"; /* 4J - TODO - get a session ID from somewhere? if (args.length > 0) name = args[0]; @@ -5148,8 +5110,8 @@ void Minecraft::tickAllConnections() bool Minecraft::addPendingClientTextureRequest(const wstring &textureName) { - auto it = find(m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName); - if( it == m_pendingTextureRequests.end() ) + AUTO_VAR(it, find( m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName)); + if( it == m_pendingTextureRequests.end() ) { m_pendingTextureRequests.push_back(textureName); return true; @@ -5159,8 +5121,8 @@ bool Minecraft::addPendingClientTextureRequest(const wstring &textureName) void Minecraft::handleClientTextureReceived(const wstring &textureName) { - auto it = find(m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName); - if( it != m_pendingTextureRequests.end() ) + AUTO_VAR(it, find( m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName)); + if( it != m_pendingTextureRequests.end() ) { m_pendingTextureRequests.erase(it); } @@ -5190,8 +5152,8 @@ int Minecraft::MustSignInReturnedPSN(void *pParam, int iPad, C4JStorage::EMessag { Minecraft* pMinecraft = (Minecraft *)pParam; - if(result == C4JStorage::EMessage_ResultAccept) - { + if(result == C4JStorage::EMessage_ResultAccept) + { SQRNetworkManager_Orbis::AttemptPSNSignIn(&Minecraft::InGame_SignInReturned, pMinecraft, false, iPad); }