From 18fb8f0294eeb78ae481aa9e205990d3bd9a079a Mon Sep 17 00:00:00 2001 From: piebot <274605694+pieeebot@users.noreply.github.com> Date: Wed, 29 Apr 2026 17:35:55 +0300 Subject: [PATCH] fix: duplicate screenshot logic --- Minecraft.Client/Minecraft.cpp | 72 ---------------------------------- 1 file changed, 72 deletions(-) diff --git a/Minecraft.Client/Minecraft.cpp b/Minecraft.Client/Minecraft.cpp index eeedcd2e..4f403e8e 100644 --- a/Minecraft.Client/Minecraft.cpp +++ b/Minecraft.Client/Minecraft.cpp @@ -3845,78 +3845,6 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) //options->thirdPersonView = !options->thirdPersonView; } -#ifdef _WINDOWS64 - if(player->ullButtonsPressed&(1LL<GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)&pBackBuffer); - if (SUCCEEDED(hr)) - { - D3D11_TEXTURE2D_DESC desc; - pBackBuffer->GetDesc(&desc); - desc.Usage = D3D11_USAGE_STAGING; - desc.BindFlags = 0; - desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; - desc.MiscFlags = 0; - - ID3D11Texture2D* pStaging = nullptr; - hr = g_pd3dDevice->CreateTexture2D(&desc, nullptr, &pStaging); - if (SUCCEEDED(hr)) - { - g_pImmediateContext->CopyResource(pStaging, pBackBuffer); - - // Build path next to the executable - wchar_t exePath[MAX_PATH]; - GetModuleFileNameW(NULL, exePath, MAX_PATH); - wchar_t* lastSlash = wcsrchr(exePath, L'\\'); - if (lastSlash) *(lastSlash + 1) = L'\0'; - wstring screenshotDirPath = wstring(exePath) + L"screenshots"; - CreateDirectoryW(screenshotDirPath.c_str(), NULL); - - SYSTEMTIME st; - GetLocalTime(&st); - wchar_t filename[128]; - swprintf_s(filename, L"%04d-%02d-%02d_%02d.%02d.%02d.png", - st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); - wstring screenshotPath = screenshotDirPath + L"\\" + filename; - - D3D11_MAPPED_SUBRESOURCE mapped; - hr = g_pImmediateContext->Map(pStaging, 0, D3D11_MAP_READ, 0, &mapped); - if (SUCCEEDED(hr)) - { - // Copy RGBA rows (back buffer is R8G8B8A8_UNORM, already RGBA) - unsigned char* rgba = new unsigned char[desc.Width * desc.Height * 4]; - for (UINT row = 0; row < desc.Height; row++) - { - unsigned char* src = (unsigned char*)mapped.pData + row * mapped.RowPitch; - unsigned char* dst = rgba + row * desc.Width * 4; - memcpy(dst, src, desc.Width * 4); - } - g_pImmediateContext->Unmap(pStaging, 0); - - // Save PNG via stb_image_write - string narrowPath(screenshotPath.begin(), screenshotPath.end()); - int writeResult = stbi_write_png(narrowPath.c_str(), desc.Width, desc.Height, 4, rgba, desc.Width * 4); - delete[] rgba; - - // Local chat message — only on success - if (writeResult) - { - wstring msg = L"Saved screenshot to " + wstring(filename); - gui->addMessage(msg, iPad); - } - } - pStaging->Release(); - } - pBackBuffer->Release(); - } - } -#endif - if((player->ullButtonsPressed&(1LL<isInputAllowed(MINECRAFT_ACTION_GAME_INFO)) { ui.NavigateToScene(iPad,eUIScene_InGameInfoMenu);