From dfdc35264d8f34a13be08d602f0327ad9f105793 Mon Sep 17 00:00:00 2001 From: NOTPIES Date: Wed, 4 Mar 2026 19:35:11 -0300 Subject: [PATCH] remove unused folders --- .../Windows_Libs/Dev/Render/RendererCore.cpp | 1071 ----------------- .../Windows_Libs/Dev/Storage/4J_Storage.cpp | 357 ------ .../Windows_Libs/Dev/Storage/STO_SaveGame.cpp | 808 ------------- .../Windows_Libs/Dev/Storage/STO_SaveGame.cpp | 2 + 4 files changed, 2 insertions(+), 2236 deletions(-) delete mode 100644 Minecraft.Client/4JLibs-master/Windows_Libs/Dev/Render/RendererCore.cpp delete mode 100644 Minecraft.Client/4JLibs-master/Windows_Libs/Dev/Storage/4J_Storage.cpp delete mode 100644 Minecraft.Client/4JLibs-master/Windows_Libs/Dev/Storage/STO_SaveGame.cpp diff --git a/Minecraft.Client/4JLibs-master/Windows_Libs/Dev/Render/RendererCore.cpp b/Minecraft.Client/4JLibs-master/Windows_Libs/Dev/Render/RendererCore.cpp deleted file mode 100644 index c2a3689..0000000 --- a/Minecraft.Client/4JLibs-master/Windows_Libs/Dev/Render/RendererCore.cpp +++ /dev/null @@ -1,1071 +0,0 @@ -/* -MIT License - -Copyright (c) 2026 Patoke - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#include "stdafx.h" -#include "Renderer.h" -#include "CompiledShaders.h" - -Renderer InternalRenderManager; - -DWORD Renderer::tlsIdx = TlsAlloc(); -_RTL_CRITICAL_SECTION Renderer::totalAllocCS = {}; - -DWORD Renderer::s_auiWidths[] = { 1920, 512, 256, 128, 64, 0 }; -DWORD Renderer::s_auiHeights[] = { 1080, 512, 256, 128, 64 }; -int Renderer::totalAlloc = 0; - -D3D11_INPUT_ELEMENT_DESC g_vertex_PTN_Elements_PF3_TF2_CB4_NB4_XW1[] = { - {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0}, - {"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0}, - {"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0}, - {"NORMAL", 0, DXGI_FORMAT_R8G8B8A8_SNORM, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0}, - {"TEXCOORD", 1, DXGI_FORMAT_R16G16_SINT, 0, 28, D3D11_INPUT_PER_VERTEX_DATA, 0}, -}; - -D3D11_INPUT_ELEMENT_DESC g_vertex_PTN_Elements_Compressed[] = { - {"POSITION", 0, DXGI_FORMAT_R16G16B16A16_SINT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0}, - {"TEXCOORD", 0, DXGI_FORMAT_R16G16B16A16_SINT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0}, -}; - -D3D11_PRIMITIVE_TOPOLOGY Renderer::g_topologies[C4JRender::PRIMITIVE_TYPE_COUNT] = { - D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST, - D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST, D3D11_PRIMITIVE_TOPOLOGY_LINELIST, D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP, -}; - -static const unsigned int kVertexBufferSize = 0x100000; -static const unsigned int kScreenGrabWidth = 1920; -static const unsigned int kScreenGrabHeight = 1080; -static const unsigned int kThumbnailSize = 64; - -static const unsigned int g_vertexStrides[C4JRender::VERTEX_TYPE_COUNT] = { 32, 16, 32, 32 }; - -Renderer::Context::Context(ID3D11Device* device, ID3D11DeviceContext* deviceContext) - : m_pDeviceContext(deviceContext) - , userAnnotation(NULL) - , annotateDepth(0) - , stackType(0) - , textureIdx(0) - , faceCullEnabled(true) - , depthTestEnabled(true) - , depthWriteEnabled(true) - , alphaTestEnabled(false) - , alphaReference(1.0f) - , fogEnabled(false) - , fogNearDistance(0.0f) - , fogFarDistance(0.0f) - , fogDensity(0.0f) - , fogColourRed(0.0f) - , fogColourGreen(0.0f) - , fogColourBlue(0.0f) - , fogMode(0) - , lightingEnabled(false) - , lightingDirty(false) - , forcedLOD(-1) - , m_modelViewMatrix(NULL) - , m_localTransformMatrix(NULL) - , m_projectionMatrix(NULL) - , m_textureMatrix(NULL) - , m_vertexTexcoordBuffer(NULL) - , m_fogParamsBuffer(NULL) - , m_lightingStateBuffer(NULL) - , m_texGenMatricesBuffer(NULL) - , m_compressedTranslationBuffer(NULL) - , m_thumbnailBoundsBuffer(NULL) - , m_tintColorBuffer(NULL) - , m_fogColourBuffer(NULL) - , m_unkColorBuffer(NULL) - , m_alphaTestBuffer(NULL) - , m_clearColorBuffer(NULL) - , m_forcedLODBuffer(NULL) - , dynamicVertexBase(0) - , dynamicVertexOffset(0) - , dynamicVertexBuffer(NULL) - , commandBuffer(NULL) - , recordingBufferIndex(0) - , recordingVertexType(0) - , recordingPrimitiveType(0) - , deferredModeEnabled(false) - , deferredBuffers() -{ - deviceContext->QueryInterface(IID_PPV_ARGS(&userAnnotation)); - memset(matrixStacks, 0, sizeof(matrixStacks)); - memset(matrixDirty, 0, sizeof(matrixDirty)); - memset(stackPos, 0, sizeof(stackPos)); - memset(lightEnabled, 0, sizeof(lightEnabled)); - memset(lightDirection, 0, sizeof(lightDirection)); - memset(lightColour, 0, sizeof(lightColour)); - memset(&lightAmbientColour, 0, sizeof(lightAmbientColour)); - memset(texGenMatrices, 0, sizeof(texGenMatrices)); - memset(&blendDesc, 0, sizeof(blendDesc)); - memset(&depthStencilDesc, 0, sizeof(depthStencilDesc)); - memset(&rasterizerDesc, 0, sizeof(rasterizerDesc)); - blendFactor[0] = 0.0f; - blendFactor[1] = 0.0f; - blendFactor[2] = 0.0f; - blendFactor[3] = 0.0f; - - const DirectX::XMMATRIX identity = DirectX::XMMatrixIdentity(); - for (UINT i = 0; i < MATRIX_MODE_MODELVIEW_MAX; ++i) - { - matrixStacks[i][0] = identity; - stackPos[i] = 0; - } - - blendDesc.AlphaToCoverageEnable = false; - blendDesc.IndependentBlendEnable = false; - blendDesc.RenderTarget[0].BlendEnable = false; - blendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE; - blendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_ZERO; - blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; - blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; - blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO; - blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; - blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; - - depthStencilDesc.DepthEnable = true; - depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL; - depthStencilDesc.DepthFunc = D3D11_COMPARISON_LESS; - depthStencilDesc.StencilEnable = false; - depthStencilDesc.StencilReadMask = 0xFF; - depthStencilDesc.StencilWriteMask = 0xFF; - depthStencilDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; - depthStencilDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP; - depthStencilDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP; - depthStencilDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS; - depthStencilDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; - depthStencilDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP; - depthStencilDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP; - depthStencilDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS; - - rasterizerDesc.FillMode = D3D11_FILL_SOLID; - rasterizerDesc.CullMode = D3D11_CULL_BACK; - rasterizerDesc.FrontCounterClockwise = true; - rasterizerDesc.DepthBias = 0; - rasterizerDesc.DepthBiasClamp = 0.0f; - rasterizerDesc.SlopeScaledDepthBias = 0.0f; - rasterizerDesc.DepthClipEnable = true; - rasterizerDesc.ScissorEnable = false; - rasterizerDesc.MultisampleEnable = true; - rasterizerDesc.AntialiasedLineEnable = false; - - memset(lightDirection, 0, sizeof(lightDirection)); - memset(lightColour, 0, sizeof(lightColour)); - memset(&lightAmbientColour, 0, sizeof(lightAmbientColour)); - memset(texGenMatrices, 0, sizeof(texGenMatrices)); - - const float zero4[4] = {0.0f, 0.0f, 0.0f, 0.0f}; - const float one4[4] = {1.0f, 1.0f, 1.0f, 1.0f}; - const float alpha4[4] = {0.0f, 0.0f, 0.0f, 1.0f}; - - D3D11_BUFFER_DESC cbDesc = {}; - cbDesc.Usage = D3D11_USAGE_DYNAMIC; - cbDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; - cbDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - - D3D11_SUBRESOURCE_DATA cbData = {}; - cbDesc.ByteWidth = sizeof(DirectX::XMMATRIX); - cbData.pSysMem = &identity; - device->CreateBuffer(&cbDesc, &cbData, &m_modelViewMatrix); - device->CreateBuffer(&cbDesc, &cbData, &m_localTransformMatrix); - device->CreateBuffer(&cbDesc, &cbData, &m_projectionMatrix); - device->CreateBuffer(&cbDesc, &cbData, &m_textureMatrix); - - cbDesc.ByteWidth = sizeof(zero4); - cbData.pSysMem = zero4; - device->CreateBuffer(&cbDesc, &cbData, &m_vertexTexcoordBuffer); - device->CreateBuffer(&cbDesc, &cbData, &m_fogParamsBuffer); - - const UINT lightingBytes = sizeof(lightDirection) + sizeof(lightColour) + sizeof(lightAmbientColour); - cbDesc.ByteWidth = lightingBytes; - cbData.pSysMem = lightDirection; - device->CreateBuffer(&cbDesc, &cbData, &m_lightingStateBuffer); - - cbDesc.ByteWidth = sizeof(texGenMatrices); - cbData.pSysMem = texGenMatrices; - device->CreateBuffer(&cbDesc, &cbData, &m_texGenMatricesBuffer); - - cbDesc.ByteWidth = sizeof(zero4); - cbData.pSysMem = zero4; - device->CreateBuffer(&cbDesc, &cbData, &m_compressedTranslationBuffer); - device->CreateBuffer(&cbDesc, &cbData, &m_thumbnailBoundsBuffer); - - cbDesc.ByteWidth = sizeof(one4); - cbData.pSysMem = one4; - device->CreateBuffer(&cbDesc, &cbData, &m_tintColorBuffer); - device->CreateBuffer(&cbDesc, &cbData, &m_fogColourBuffer); - device->CreateBuffer(&cbDesc, &cbData, &m_unkColorBuffer); - - cbDesc.ByteWidth = sizeof(alpha4); - cbData.pSysMem = alpha4; - device->CreateBuffer(&cbDesc, &cbData, &m_alphaTestBuffer); - - cbDesc.ByteWidth = sizeof(zero4); - cbData.pSysMem = zero4; - device->CreateBuffer(&cbDesc, &cbData, &m_clearColorBuffer); - device->CreateBuffer(&cbDesc, &cbData, &m_forcedLODBuffer); - - deviceContext->VSSetConstantBuffers(0, 10, &m_modelViewMatrix); - deviceContext->PSSetConstantBuffers(0, 6, &m_tintColorBuffer); - - { - void *dynamicVertexPtr = operator new[](kVertexBufferSize); - dynamicVertexBase = reinterpret_cast(dynamicVertexPtr); - } - dynamicVertexOffset = 0; - - D3D11_BUFFER_DESC vbDesc = {}; - vbDesc.ByteWidth = kVertexBufferSize; - vbDesc.Usage = D3D11_USAGE_DYNAMIC; - vbDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; - vbDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - device->CreateBuffer(&vbDesc, NULL, &dynamicVertexBuffer); -} - -void Renderer::BeginConditionalRendering(int) {} - -void Renderer::BeginConditionalSurvey(int) {} - -void Renderer::CaptureScreen(ImageFileBuffer *, XSOCIAL_PREVIEWIMAGE *) {} - -void Renderer::Clear(int flags, D3D11_RECT *) -{ - PROFILER_SCOPE("Renderer::Clear", "Clear", MP_MAGENTA) - - Renderer::Context &c = getContext(); - - ID3D11BlendState *blendState = NULL; - ID3D11DepthStencilState *depthState = NULL; - ID3D11RasterizerState *rasterizerState = NULL; - - PROFILER_SCOPE("Renderer::Clear", "Blend", MP_MAGENTA) - D3D11_BLEND_DESC blendDesc = {}; - blendDesc.AlphaToCoverageEnable = false; - blendDesc.IndependentBlendEnable = false; - blendDesc.RenderTarget[0].BlendEnable = false; - blendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE; - blendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_ZERO; - blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; - blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; - blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO; - blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; - blendDesc.RenderTarget[0].RenderTargetWriteMask = (flags & CLEAR_COLOUR_FLAG) ? D3D11_COLOR_WRITE_ENABLE_ALL : 0; - m_pDevice->CreateBlendState(&blendDesc, &blendState); - - PROFILER_SCOPE("Renderer::Clear", "Depth", MP_MAGENTA) - D3D11_DEPTH_STENCIL_DESC depthDesc = {}; - depthDesc.DepthEnable = (flags & CLEAR_DEPTH_FLAG) ? true : false; - depthDesc.DepthWriteMask = depthDesc.DepthEnable ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO; - depthDesc.DepthFunc = D3D11_COMPARISON_ALWAYS; - depthDesc.StencilEnable = false; - depthDesc.StencilReadMask = 0xFF; - depthDesc.StencilWriteMask = 0xFF; - depthDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; - depthDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP; - depthDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP; - depthDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS; - depthDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; - depthDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP; - depthDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP; - depthDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS; - m_pDevice->CreateDepthStencilState(&depthDesc, &depthState); - - PROFILER_SCOPE("Renderer::Clear", "Rasterizer", MP_MAGENTA) - D3D11_RASTERIZER_DESC rasterDesc = {}; - rasterDesc.FillMode = D3D11_FILL_SOLID; - rasterDesc.CullMode = D3D11_CULL_NONE; - rasterDesc.DepthClipEnable = true; - rasterDesc.MultisampleEnable = true; - m_pDevice->CreateRasterizerState(&rasterDesc, &rasterizerState); - - PROFILER_SCOPE("Renderer::Clear", "DrawClearQuad", MP_MAGENTA) - c.m_pDeviceContext->VSSetShader(screenClearVertexShader, NULL, 0); - c.m_pDeviceContext->IASetInputLayout(NULL); - c.m_pDeviceContext->PSSetShader(screenClearPixelShader, NULL, 0); - c.m_pDeviceContext->OMSetRenderTargets(1, &renderTargetView, depthStencilView); - c.m_pDeviceContext->OMSetBlendState(blendState, NULL, 0xFFFFFFFF); - c.m_pDeviceContext->OMSetDepthStencilState(depthState, 0); - c.m_pDeviceContext->RSSetState(rasterizerState); - c.m_pDeviceContext->PSSetShaderResources(0, 0, NULL); - c.m_pDeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); - c.m_pDeviceContext->Draw(4, 0); - - if (blendState) - { - blendState->Release(); - blendState = NULL; - } - if (depthState) - { - depthState->Release(); - depthState = NULL; - } - if (rasterizerState) - { - rasterizerState->Release(); - rasterizerState = NULL; - } - - c.m_pDeviceContext->OMSetBlendState(GetManagedBlendState(), c.blendFactor, 0xFFFFFFFF); - c.m_pDeviceContext->OMSetDepthStencilState(GetManagedDepthStencilState(), 0); - c.m_pDeviceContext->RSSetState(GetManagedRasterizerState()); - c.m_pDeviceContext->OMSetRenderTargets(1, &renderTargetView, depthStencilView); - - activeVertexType = -1; - activePixelType = -1; -} - -void Renderer::ConvertLinearToPng(ImageFileBuffer *pngOut, unsigned char *linearData, unsigned int width, unsigned int height) -{ - const size_t dataSize = static_cast(width) * static_cast(height) * 4; - const size_t outputCapacity = (dataSize * 24) / 20 + 256; - - void *outputBuffer = malloc(outputCapacity); - int outputLength = 0; - - SaveTextureDataToMemory( - outputBuffer, - static_cast(outputCapacity), - &outputLength, - static_cast(width), - static_cast(height), - reinterpret_cast(linearData) - ); - - pngOut->m_type = ImageFileBuffer::e_typePNG; - pngOut->m_pBuffer = outputBuffer; - pngOut->m_bufferSize = outputLength; -} - -void Renderer::DoScreenGrabOnNextPresent() -{ - m_bShouldScreenGrabNextFrame = true; -} - -void Renderer::EndConditionalRendering() {} -void Renderer::EndConditionalSurvey() {} - -void Renderer::BeginEvent(LPCWSTR eventName) -{ - Renderer::Context &c = Renderer::getContext(); - if (c.m_pDeviceContext->GetType() != D3D11_DEVICE_CONTEXT_DEFERRED && c.userAnnotation) - { - c.userAnnotation->BeginEvent(eventName); - ++c.annotateDepth; - } -} - -void Renderer::EndEvent() -{ - Renderer::Context &c = Renderer::getContext(); - if (c.m_pDeviceContext->GetType() != D3D11_DEVICE_CONTEXT_DEFERRED && c.userAnnotation) - { - c.userAnnotation->EndEvent(); - --c.annotateDepth; - assert(c.annotateDepth >= 0); - } -} - -void Renderer::Initialise(ID3D11Device *pDevice, IDXGISwapChain *pSwapChain) -{ - m_pDevice = pDevice; - m_pDeviceContext = InitialiseContext(true); - m_pSwapChain = pSwapChain; - - #ifdef ENABLE_PROFILING - MicroProfileOnThreadCreate("MainRenderThread"); - MicroProfileSetEnableAllGroups(true); - #endif - - m_commandHandleToIndex = new int16_t[NUM_COMMAND_HANDLES]; - m_commandBuffers = new CommandBuffer *[MAX_COMMAND_BUFFERS]; - m_commandMatrices = new DirectX::XMMATRIX[MAX_COMMAND_BUFFERS]; - m_commandIndexToHandle = new int[MAX_COMMAND_BUFFERS]; - m_commandVertexTypes = new uint8_t[MAX_COMMAND_BUFFERS]; - m_commandPrimitiveTypes = new uint8_t[MAX_COMMAND_BUFFERS]; - - memset(m_commandHandleToIndex, 0xFF, NUM_COMMAND_HANDLES * sizeof(int16_t)); - memset(m_commandBuffers, 0, MAX_COMMAND_BUFFERS * sizeof(CommandBuffer*)); - memset(m_commandIndexToHandle, 0, MAX_COMMAND_BUFFERS * sizeof(int)); - memset(m_commandVertexTypes, 0, MAX_COMMAND_BUFFERS * sizeof(uint8_t)); - memset(m_commandPrimitiveTypes, 0, MAX_COMMAND_BUFFERS * sizeof(uint8_t)); - - reservedRendererDword3 = 0; - m_bShouldScreenGrabNextFrame = false; - m_bSuspended = false; - - SetupShaders(); - const float clearColour[4] = {0.0f, 0.0f, 0.0f, 0.0f}; - SetClearColour(clearColour); - - UINT backBufferSampleCount = 1; - UINT backBufferSampleQuality = 0; - - ID3D11Texture2D *backBuffer = NULL; - pSwapChain->GetBuffer(0, IID_PPV_ARGS(&backBuffer)); - if (backBuffer) - { - D3D11_TEXTURE2D_DESC backDesc = {}; - backBuffer->GetDesc(&backDesc); - backBufferWidth = backDesc.Width; - backBufferHeight = backDesc.Height; - backBufferSampleCount = backDesc.SampleDesc.Count; - backBufferSampleQuality = backDesc.SampleDesc.Quality; - - m_pDevice->CreateRenderTargetView(backBuffer, NULL, &renderTargetView); - - D3D11_TEXTURE2D_DESC srvDesc = backDesc; - srvDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE; - srvDesc.MiscFlags = 0; - - ID3D11Texture2D *srvTexture = NULL; - m_pDevice->CreateTexture2D(&srvDesc, NULL, &srvTexture); - m_pDevice->CreateShaderResourceView(srvTexture, NULL, &renderTargetShaderResourceView); - - srvTexture->Release(); - backBuffer->Release(); - } - - ID3D11RenderTargetView *boundRTV = NULL; - m_pDeviceContext->OMGetRenderTargets(1, &boundRTV, &depthStencilView); - if (boundRTV) - boundRTV->Release(); - - if (!depthStencilView && backBufferWidth != 0 && backBufferHeight != 0) - { - D3D11_TEXTURE2D_DESC depthDesc = {}; - depthDesc.Width = backBufferWidth; - depthDesc.Height = backBufferHeight; - depthDesc.MipLevels = 1; - depthDesc.ArraySize = 1; - depthDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; - depthDesc.SampleDesc.Count = backBufferSampleCount; - depthDesc.SampleDesc.Quality = backBufferSampleQuality; - depthDesc.Usage = D3D11_USAGE_DEFAULT; - depthDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL; - - ID3D11Texture2D *depthTexture = NULL; - if (SUCCEEDED(m_pDevice->CreateTexture2D(&depthDesc, NULL, &depthTexture))) - { - m_pDevice->CreateDepthStencilView(depthTexture, NULL, &depthStencilView); - depthTexture->Release(); - } - } - - D3D11_TEXTURE2D_DESC desc = {}; - desc.MipLevels = 1; - desc.ArraySize = 1; - desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - desc.SampleDesc.Count = 1; - desc.Usage = D3D11_USAGE_DEFAULT; - desc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE; - desc.CPUAccessFlags = 0; - desc.MiscFlags = 0; - for (UINT i = 0; i < MAX_MIP_LEVELS - 1; ++i) - { - desc.Width = s_auiWidths[i + 1]; - desc.Height = s_auiHeights[i + 1]; - - HRESULT hr = m_pDevice->CreateTexture2D(&desc, NULL, &renderTargetTextures[i]); - assert(hr == S_OK); - - hr = m_pDevice->CreateRenderTargetView(renderTargetTextures[i], NULL, &renderTargetViews[i]); - assert(hr == S_OK); - - hr = m_pDevice->CreateShaderResourceView(renderTargetTextures[i], NULL, &renderTargetShaderResourceViews[i]); - assert(hr == S_OK); - } - - memset(m_textures, 0, sizeof(m_textures)); - defaultTextureIndex = TextureCreate(); - TextureBind(defaultTextureIndex); - - unsigned char *defaultTextureData = new unsigned char[0x400]; - memset(defaultTextureData, 0xFF, 0x400); - TextureData(16, 16, defaultTextureData, 0, C4JRender::TEXTURE_FORMAT_RxGyBzAw); - delete[] defaultTextureData; - - presentCount = 0; - rendererFlag0 = 0; - reservedRendererWord0 = 10922; - StateSetViewport(C4JRender::VIEWPORT_TYPE_FULLSCREEN); - StateSetVertexTextureUV(0.0f, 0.0f); - TextureBindVertex(-1); - - InitializeCriticalSection(&m_commandBufferCS); - - reservedRendererDword1 = 0; - activeVertexType = -1; - activePixelType = -1; - reservedRendererByte1 = 1; - reservedRendererByte0 = 0; - - unsigned short *quadIndices = new unsigned short[0x18000]; - for (UINT i = 0; i < 0x4000; ++i) - { - unsigned short base = static_cast(i * 4); - unsigned int offset = i * 6; - quadIndices[offset + 0] = base; - quadIndices[offset + 1] = base + 1; - quadIndices[offset + 2] = base + 3; - quadIndices[offset + 3] = base + 1; - quadIndices[offset + 4] = base + 2; - quadIndices[offset + 5] = base + 3; - } - - D3D11_BUFFER_DESC quadIndexDesc = {}; - quadIndexDesc.ByteWidth = 0x30000; - quadIndexDesc.Usage = D3D11_USAGE_IMMUTABLE; - quadIndexDesc.BindFlags = D3D11_BIND_INDEX_BUFFER; - quadIndexDesc.CPUAccessFlags = 0; - quadIndexDesc.MiscFlags = 0; - - D3D11_SUBRESOURCE_DATA quadIndexData = {}; - quadIndexData.pSysMem = quadIndices; - HRESULT hr = m_pDevice->CreateBuffer(&quadIndexDesc, &quadIndexData, &quadIndexBuffer); - assert(hr >= 0); - delete[] quadIndices; - - unsigned short *fanIndices = new unsigned short[0x2FFFA]; - for (UINT i = 0; i < 65534; ++i) - { - unsigned int offset = i * 3; - fanIndices[offset + 0] = 0; - fanIndices[offset + 1] = static_cast(i + 1); - fanIndices[offset + 2] = static_cast(i + 2); - } - - D3D11_BUFFER_DESC fanIndexDesc = {}; - fanIndexDesc.ByteWidth = 0x5FFF4; - fanIndexDesc.Usage = D3D11_USAGE_IMMUTABLE; - fanIndexDesc.BindFlags = D3D11_BIND_INDEX_BUFFER; - - D3D11_SUBRESOURCE_DATA fanIndexData = {}; - fanIndexData.pSysMem = fanIndices; - m_pDevice->CreateBuffer(&fanIndexDesc, &fanIndexData, &fanIndexBuffer); - delete[] fanIndices; - - InitializeCriticalSection(&Renderer::totalAllocCS); -} - -ID3D11DeviceContext *Renderer::InitialiseContext(bool fromPresent) -{ - ID3D11DeviceContext *deviceContext = NULL; - - if (fromPresent) - m_pDevice->GetImmediateContext(&deviceContext); - else - m_pDevice->CreateDeferredContext(0, &deviceContext); - - Renderer::Context *c = new (std::nothrow) Renderer::Context(m_pDevice, deviceContext); - TlsSetValue(Renderer::tlsIdx, c); - - return deviceContext; -} - -bool Renderer::IsHiDef() -{ - return true; -} - -bool Renderer::IsWidescreen() -{ - return true; -} - -void Renderer::Present() -{ - PROFILER_SCOPE("Renderer::Present", "Present", MP_MAGENTA) - - if (m_bShouldScreenGrabNextFrame) - { - PROFILER_SCOPE("Renderer::Present", "ScreenGrab", MP_MAGENTA) - - unsigned char *linearData = new unsigned char[kScreenGrabWidth * kScreenGrabHeight * 4]; - - ID3D11Texture2D *backBuffer = NULL; - ID3D11Texture2D *stagingTexture = NULL; - - m_pSwapChain->GetBuffer(0, IID_PPV_ARGS(&backBuffer)); - if (backBuffer) - { - D3D11_TEXTURE2D_DESC desc = {}; - backBuffer->GetDesc(&desc); - desc.Usage = D3D11_USAGE_STAGING; - desc.BindFlags = 0; - desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; - desc.MiscFlags = 0; - m_pDevice->CreateTexture2D(&desc, NULL, &stagingTexture); - } - - if (stagingTexture && backBuffer) - { - PROFILER_SCOPE("Renderer::Present", "CopyResource", MP_MAGENTA) - m_pDeviceContext->CopyResource(stagingTexture, backBuffer); - - D3D11_MAPPED_SUBRESOURCE mapped = {}; - if (SUCCEEDED(m_pDeviceContext->Map(stagingTexture, 0, D3D11_MAP_READ, 0, &mapped))) - { - const unsigned char *src = reinterpret_cast(mapped.pData); - - for (UINT y = 0; y < kScreenGrabHeight; ++y) - { - unsigned char *dstRow = linearData + y * kScreenGrabWidth * 4; - const unsigned char *srcRow = src + y * mapped.RowPitch; - memcpy(dstRow, srcRow, kScreenGrabWidth * 4); - - for (UINT x = 0; x < kScreenGrabWidth; ++x) - dstRow[x * 4 + 3] = 0xFF; - } - - m_pDeviceContext->Unmap(stagingTexture, 0); - } - } - - static int count = 0; - char fileName[304]; - sprintf_s(fileName, "d:\\screen%d.png", count++); - - D3DXIMAGE_INFO info; - info.Width = kScreenGrabWidth; - info.Height = kScreenGrabHeight; - SaveTextureData(fileName, &info, reinterpret_cast(linearData)); - - delete[] linearData; - - if (stagingTexture) - { - stagingTexture->Release(); - stagingTexture = NULL; - } - if (backBuffer) - { - backBuffer->Release(); - backBuffer = NULL; - } - - m_bShouldScreenGrabNextFrame = false; - } - - m_pSwapChain->Present(1, 0); - ++presentCount; -} - -void Renderer::Resume() -{ - m_bSuspended = false; -} - -void Renderer::SetClearColour(const float colourRGBA[4]) -{ - for (int i = 0; i < 4; ++i) - m_fClearColor[i] = colourRGBA[i]; - - Renderer::Context &c = getContext(); - if (&c) - { - D3D11_MAPPED_SUBRESOURCE mapped = {}; - if (SUCCEEDED(c.m_pDeviceContext->Map(c.m_clearColorBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped))) - { - *(DirectX::XMVECTOR*)mapped.pData = DirectX::XMVectorSet(colourRGBA[0], colourRGBA[1], colourRGBA[2], colourRGBA[3]); - c.m_pDeviceContext->Unmap(c.m_clearColorBuffer, 0); - } - } -} - -void Renderer::SetupShaders() -{ - vertexShaderTable = new ID3D11VertexShader *[C4JRender::VERTEX_TYPE_COUNT]; - pixelShaderTable = new ID3D11PixelShader *[C4JRender::PIXEL_SHADER_COUNT]; - vertexStrideTable = new unsigned int[C4JRender::VERTEX_TYPE_COUNT]; - inputLayoutTable = new ID3D11InputLayout *[C4JRender::VERTEX_TYPE_COUNT]; - - for (UINT i = 0; i < C4JRender::VERTEX_TYPE_COUNT; ++i) - { - vertexShaderTable[i] = NULL; - inputLayoutTable[i] = NULL; - vertexStrideTable[i] = g_vertexStrides[i]; - } - - for (UINT i = 0; i < C4JRender::PIXEL_SHADER_COUNT; ++i) - { - pixelShaderTable[i] = NULL; - } - - screenSpaceVertexShader = NULL; - screenClearVertexShader = NULL; - screenSpacePixelShader = NULL; - screenClearPixelShader = NULL; - - m_pDevice->CreateVertexShader(g_main_VS_PF3_TF2_CB4_NB4_XW1, sizeof(g_main_VS_PF3_TF2_CB4_NB4_XW1), NULL, &vertexShaderTable[C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1]); - m_pDevice->CreateVertexShader(g_main_VS_Compressed, sizeof(g_main_VS_Compressed), NULL, &vertexShaderTable[C4JRender::VERTEX_TYPE_COMPRESSED]); - m_pDevice->CreateVertexShader(g_main_VS_PF3_TF2_CB4_NB4_XW1_LIGHTING, sizeof(g_main_VS_PF3_TF2_CB4_NB4_XW1_LIGHTING), NULL, &vertexShaderTable[C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_LIT]); - m_pDevice->CreateVertexShader(g_main_VS_PF3_TF2_CB4_NB4_XW1_TEXGEN, sizeof(g_main_VS_PF3_TF2_CB4_NB4_XW1_TEXGEN), NULL, &vertexShaderTable[C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_TEXGEN]); - m_pDevice->CreateVertexShader(g_main_VS_ScreenSpace, sizeof(g_main_VS_ScreenSpace), NULL, &screenSpaceVertexShader); - m_pDevice->CreateVertexShader(g_main_VS_ScreenClear, sizeof(g_main_VS_ScreenClear), NULL, &screenClearVertexShader); - - m_pDevice->CreatePixelShader(g_main_PS_Standard, sizeof(g_main_PS_Standard), NULL, &pixelShaderTable[C4JRender::PIXEL_SHADER_TYPE_STANDARD]); - m_pDevice->CreatePixelShader(g_main_PS_TextureProjection, sizeof(g_main_PS_TextureProjection), NULL, &pixelShaderTable[C4JRender::PIXEL_SHADER_TYPE_PROJECTION]); - m_pDevice->CreatePixelShader(g_main_PS_ForceLOD, sizeof(g_main_PS_ForceLOD), NULL, &pixelShaderTable[C4JRender::PIXEL_SHADER_TYPE_FORCELOD]); - m_pDevice->CreatePixelShader(g_main_PS_ScreenSpace, sizeof(g_main_PS_ScreenSpace), NULL, &screenSpacePixelShader); - m_pDevice->CreatePixelShader(g_main_PS_ScreenClear, sizeof(g_main_PS_ScreenClear), NULL, &screenClearPixelShader); - - m_pDevice->CreateInputLayout(g_vertex_PTN_Elements_PF3_TF2_CB4_NB4_XW1, 5, g_main_VS_PF3_TF2_CB4_NB4_XW1, sizeof(g_main_VS_PF3_TF2_CB4_NB4_XW1), &inputLayoutTable[C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1]); - m_pDevice->CreateInputLayout(g_vertex_PTN_Elements_Compressed, 2, g_main_VS_Compressed, sizeof(g_main_VS_Compressed), &inputLayoutTable[C4JRender::VERTEX_TYPE_COMPRESSED]); - m_pDevice->CreateInputLayout(g_vertex_PTN_Elements_PF3_TF2_CB4_NB4_XW1, 5, g_main_VS_PF3_TF2_CB4_NB4_XW1_LIGHTING, sizeof(g_main_VS_PF3_TF2_CB4_NB4_XW1_LIGHTING), &inputLayoutTable[C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_LIT]); - m_pDevice->CreateInputLayout(g_vertex_PTN_Elements_PF3_TF2_CB4_NB4_XW1, 5, g_main_VS_PF3_TF2_CB4_NB4_XW1_TEXGEN, sizeof(g_main_VS_PF3_TF2_CB4_NB4_XW1_TEXGEN), &inputLayoutTable[C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_TEXGEN]); -} - -void Renderer::StartFrame() -{ - PROFILER_SCOPE("Renderer::StartFrame", "StartFrame", MP_MAGENTA) - - Renderer::Context &c = getContext(); - - activeVertexType = -1; - activePixelType = -1; - - TextureBindVertex(-1); - TextureBind(-1); - - PROFILER_SCOPE("Renderer::StartFrame", "State", MP_MAGENTA) - - StateSetColour(1.0f, 1.0f, 1.0f, 1.0f); - StateSetDepthMask(true); - StateSetBlendEnable(true); - StateSetBlendFunc(D3D11_BLEND_SRC_ALPHA, D3D11_BLEND_INV_SRC_ALPHA); - StateSetBlendFactor(0xFFFFFFFF); - StateSetAlphaFunc(D3D11_COMPARISON_GREATER, 0.1f); - StateSetDepthFunc(D3D11_COMPARISON_LESS_EQUAL); - StateSetFaceCull(true); - StateSetLineWidth(1.0f); - StateSetWriteEnable(true, true, true, true); - StateSetDepthTestEnable(false); - StateSetAlphaTestEnable(true); - - c.m_pDeviceContext->VSSetConstantBuffers(0, 10, &c.m_modelViewMatrix); - c.m_pDeviceContext->PSSetConstantBuffers(0, 6, &c.m_tintColorBuffer); - - D3D11_VIEWPORT viewport = {}; - viewport.TopLeftX = 0.0f; - viewport.TopLeftY = 0.0f; - viewport.Width = (float)backBufferWidth; - viewport.Height = (float)backBufferHeight; - viewport.MinDepth = 0.0f; - viewport.MaxDepth = 1.0f; - c.m_pDeviceContext->RSSetViewports(1, &viewport); - c.m_pDeviceContext->OMSetRenderTargets(1, &renderTargetView, depthStencilView); - - #ifdef ENABLE_PROFILING - MicroProfileFlip(nullptr); - #endif -} - -void Renderer::Suspend() -{ - m_bSuspended = true; -} - -bool Renderer::Suspended() -{ - return m_bSuspended; -} - -void Renderer::UpdateGamma(unsigned short) {} - -Renderer::Context &Renderer::getContext() -{ - return *reinterpret_cast(TlsGetValue(Renderer::tlsIdx)); -} - -void Renderer::CaptureThumbnail(ImageFileBuffer *pngOut) -{ - Renderer::Context &c = getContext(); - - float left = 0.0f; - float bottom = 0.0f; - float right = 1.0f; - float top = 1.0f; - - switch (m_ViewportType) - { - case C4JRender::VIEWPORT_TYPE_SPLIT_TOP: - bottom = 0.5f; - break; - case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM: - top = 0.5f; - break; - case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT: - right = 0.5f; - break; - case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT: - left = 0.5f; - break; - case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT: - right = 0.5f; - bottom = 0.5f; - break; - case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT: - left = 0.5f; - bottom = 0.5f; - break; - case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT: - right = 0.5f; - top = 0.5f; - break; - case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT: - left = 0.5f; - top = 0.5f; - break; - default: - break; - } - - float aspectRatio = IsWidescreen() ? (16.0f / 9.0f) : (4.0f / 3.0f); - - right *= aspectRatio; - left *= aspectRatio; - - float width = right - left; - float height = top - bottom; - - if (height > width) - { - float diff = (height - width) * 0.5f; - bottom += diff; - top -= diff; - } - else - { - float diff = (width - height) * 0.5f; - left += diff; - right -= diff; - } - - left /= aspectRatio; - right /= aspectRatio; - - { - ID3D11Texture2D *backBuffer = NULL; - m_pSwapChain->GetBuffer(0, IID_PPV_ARGS(&backBuffer)); - if (backBuffer && renderTargetShaderResourceView) - { - ID3D11Resource *srvResource = NULL; - renderTargetShaderResourceView->GetResource(&srvResource); - if (srvResource) - { - c.m_pDeviceContext->CopyResource(srvResource, backBuffer); - srvResource->Release(); - } - backBuffer->Release(); - } - else if (backBuffer) - { - backBuffer->Release(); - } - } - - ID3D11BlendState *blendState = NULL; - ID3D11DepthStencilState *depthState = NULL; - ID3D11RasterizerState *rasterizerState = NULL; - ID3D11SamplerState *samplerState = NULL; - ID3D11Texture2D *stagingTexture = NULL; - - D3D11_BLEND_DESC blendDesc = {}; - blendDesc.RenderTarget[0].BlendEnable = false; - blendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE; - blendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_ZERO; - blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; - blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; - blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO; - blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; - blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; - m_pDevice->CreateBlendState(&blendDesc, &blendState); - - D3D11_DEPTH_STENCIL_DESC depthDesc = {}; - depthDesc.DepthEnable = false; - depthDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO; - depthDesc.DepthFunc = D3D11_COMPARISON_ALWAYS; - depthDesc.StencilEnable = false; - depthDesc.StencilReadMask = 0xFF; - depthDesc.StencilWriteMask = 0xFF; - depthDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; - depthDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP; - depthDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP; - depthDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS; - depthDesc.BackFace = depthDesc.FrontFace; - m_pDevice->CreateDepthStencilState(&depthDesc, &depthState); - - D3D11_RASTERIZER_DESC rasterDesc = {}; - rasterDesc.FillMode = D3D11_FILL_SOLID; - rasterDesc.CullMode = D3D11_CULL_NONE; - rasterDesc.DepthClipEnable = true; - rasterDesc.MultisampleEnable = true; - m_pDevice->CreateRasterizerState(&rasterDesc, &rasterizerState); - - D3D11_SAMPLER_DESC samplerDesc = {}; - samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; - samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP; - samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP; - samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP; - samplerDesc.MaxAnisotropy = 1; - samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS; - samplerDesc.MinLOD = 0.0f; - samplerDesc.MaxLOD = (std::numeric_limits::max)(); - m_pDevice->CreateSamplerState(&samplerDesc, &samplerState); - - c.m_pDeviceContext->VSSetShader(screenSpaceVertexShader, NULL, 0); - c.m_pDeviceContext->IASetInputLayout(NULL); - c.m_pDeviceContext->PSSetShader(screenSpacePixelShader, NULL, 0); - c.m_pDeviceContext->OMSetBlendState(blendState, NULL, -1); - c.m_pDeviceContext->OMSetDepthStencilState(depthState, 0); - c.m_pDeviceContext->RSSetState(rasterizerState); - - for (UINT i = 0; i < MAX_MIP_LEVELS - 1; ++i) - { - D3D11_VIEWPORT viewport = {}; - viewport.TopLeftX = 0.0f; - viewport.TopLeftY = 0.0f; - viewport.Width = (float)s_auiWidths[i + 1]; - viewport.Height = (float)s_auiHeights[i + 1]; - viewport.MinDepth = 0.0f; - viewport.MaxDepth = 1.0f; - - c.m_pDeviceContext->OMSetRenderTargets(1, &renderTargetViews[i], NULL); - c.m_pDeviceContext->RSSetViewports(1, &viewport); - - ID3D11ShaderResourceView *inputTexture = (i == 0) ? renderTargetShaderResourceView : renderTargetShaderResourceViews[i - 1]; - c.m_pDeviceContext->PSSetShaderResources(0, 1, &inputTexture); - c.m_pDeviceContext->PSSetSamplers(0, 1, &samplerState); - c.m_pDeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); - - D3D11_MAPPED_SUBRESOURCE mapped = {}; - c.m_pDeviceContext->Map(c.m_thumbnailBoundsBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped); - - float *constants = (float *)mapped.pData; - if (i == 0) - { - constants[0] = left; - constants[1] = bottom; - constants[2] = right - left; - constants[3] = top - bottom; - } - else - { - constants[0] = 0.0f; - constants[1] = 0.0f; - constants[2] = 1.0f; - constants[3] = 1.0f; - } - - c.m_pDeviceContext->Unmap(c.m_thumbnailBoundsBuffer, 0); - c.m_pDeviceContext->Draw(4, 0); - } - - D3D11_TEXTURE2D_DESC texDesc = {}; - renderTargetTextures[MAX_MIP_LEVELS - 2]->GetDesc(&texDesc); - texDesc.Usage = D3D11_USAGE_STAGING; - texDesc.BindFlags = 0; - texDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; - texDesc.MiscFlags = 0; - m_pDevice->CreateTexture2D(&texDesc, NULL, &stagingTexture); - - const unsigned int stride = kThumbnailSize * 4; - unsigned char *linearData = new unsigned char[kThumbnailSize * stride]; - - if (stagingTexture) - { - c.m_pDeviceContext->CopyResource(stagingTexture, renderTargetTextures[MAX_MIP_LEVELS - 2]); - - D3D11_MAPPED_SUBRESOURCE mapped = {}; - if (SUCCEEDED(c.m_pDeviceContext->Map(stagingTexture, 0, D3D11_MAP_READ, 0, &mapped))) - { - const unsigned char *src = static_cast(mapped.pData); - unsigned char *dst = linearData; - - for (UINT y = 0; y < kThumbnailSize; ++y) - { - memcpy(dst, src, stride); - - unsigned char *alpha = dst + 3; - for (UINT x = 0; x < kThumbnailSize; ++x) - { - *alpha = 0xFF; - alpha += 4; - } - - src += mapped.RowPitch; - dst += stride; - } - - c.m_pDeviceContext->Unmap(stagingTexture, 0); - } - } - - ConvertLinearToPng(pngOut, linearData, kThumbnailSize, kThumbnailSize); - delete[] linearData; - - if (stagingTexture) - { - stagingTexture->Release(); - stagingTexture = NULL; - } - if (samplerState) - { - samplerState->Release(); - samplerState = NULL; - } - if (rasterizerState) - { - rasterizerState->Release(); - rasterizerState = NULL; - } - if (depthState) - { - depthState->Release(); - depthState = NULL; - } - if (blendState) - { - blendState->Release(); - blendState = NULL; - } - - c.m_pDeviceContext->OMSetBlendState(GetManagedBlendState(), c.blendFactor, -1); - c.m_pDeviceContext->OMSetDepthStencilState(GetManagedDepthStencilState(), 0); - c.m_pDeviceContext->RSSetState(GetManagedRasterizerState()); - - D3D11_VIEWPORT viewport = {}; - viewport.TopLeftX = 0.0f; - viewport.TopLeftY = 0.0f; - viewport.Width = (float)backBufferWidth; - viewport.Height = (float)backBufferHeight; - viewport.MinDepth = 0.0f; - viewport.MaxDepth = 1.0f; - - c.m_pDeviceContext->RSSetViewports(1, &viewport); - c.m_pDeviceContext->OMSetRenderTargets(1, &renderTargetView, depthStencilView); - - activeVertexType = -1; - activePixelType = -1; -} diff --git a/Minecraft.Client/4JLibs-master/Windows_Libs/Dev/Storage/4J_Storage.cpp b/Minecraft.Client/4JLibs-master/Windows_Libs/Dev/Storage/4J_Storage.cpp deleted file mode 100644 index 8785e62..0000000 --- a/Minecraft.Client/4JLibs-master/Windows_Libs/Dev/Storage/4J_Storage.cpp +++ /dev/null @@ -1,357 +0,0 @@ -/* -MIT License - -Copyright (c) 2026 Patoke - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#include "4J_Storage.h" -#include "STO_Main.h" - -C4JStorage StorageManager; -XMARKETPLACE_CONTENTOFFER_INFO InternalContentOfferInfo; - -C4JStorage::C4JStorage() {} - -void C4JStorage::Tick(void) -{ - InternalStorageManager.Tick(); -} - -C4JStorage::EMessageResult C4JStorage::RequestMessageBox(UINT uiTitle, UINT uiText, UINT *uiOptionA, UINT uiOptionC, DWORD dwPad, - int (*Func)(LPVOID, int, const C4JStorage::EMessageResult), LPVOID lpParam, - C4JStringTable *pStringTable, WCHAR *pwchFormatString, DWORD dwFocusButton) -{ - return EMessage_Undefined; -} - -C4JStorage::EMessageResult C4JStorage::GetMessageBoxResult() -{ - return EMessage_Undefined; -} - -bool C4JStorage::SetSaveDevice(int (*Func)(LPVOID, const bool), LPVOID lpParam, bool bForceResetOfSaveDevice) -{ - return true; -} - -void C4JStorage::Init(unsigned int uiSaveVersion, LPCWSTR pwchDefaultSaveName, char *pszSavePackName, int iMinimumSaveSize, - int (*Func)(LPVOID, const ESavingMessage, int), LPVOID lpParam, LPCSTR szGroupID) -{ - InternalStorageManager.Init(Func, lpParam, szGroupID); -} - -void C4JStorage::ResetSaveData() -{ - InternalStorageManager.m_SaveGame.ResetSaveData(); -} - -void C4JStorage::SetDefaultSaveNameForKeyboardDisplay(LPCWSTR pwchDefaultSaveName) -{ - ; -} - -void C4JStorage::SetSaveTitle(LPCWSTR pwchDefaultSaveName) -{ - InternalStorageManager.m_SaveGame.SetSaveTitle(pwchDefaultSaveName); -} - -LPCWSTR C4JStorage::GetSaveTitle() -{ - return InternalStorageManager.m_SaveGame.GetSaveTitle(); -} - -bool C4JStorage::GetSaveUniqueNumber(INT *piVal) -{ - return InternalStorageManager.m_SaveGame.GetSaveUniqueNumber(piVal); -} - -bool C4JStorage::GetSaveUniqueFilename(char *pszName) -{ - return InternalStorageManager.m_SaveGame.GetSaveUniqueFilename(pszName); -} - -void C4JStorage::SetSaveUniqueFilename(char *szFilename) -{ - InternalStorageManager.m_SaveGame.SetSaveUniqueFilename(szFilename); -} - -void C4JStorage::SetState(ESaveGameControlState eControlState, int (*Func)(LPVOID, const bool), LPVOID lpParam) -{ - ; -} - -void C4JStorage::SetSaveDisabled(bool bDisable) -{ - InternalStorageManager.m_SaveGame.SetSaveDisabled(bDisable); -} - -bool C4JStorage::GetSaveDisabled(void) -{ - return InternalStorageManager.m_SaveGame.GetSaveDisabled(); -} - -unsigned int C4JStorage::GetSaveSize() -{ - return InternalStorageManager.m_SaveGame.GetSaveSize(); -} - -void C4JStorage::GetSaveData(void *pvData, unsigned int *puiBytes) -{ - InternalStorageManager.m_SaveGame.GetSaveData(pvData, puiBytes); -} - -PVOID C4JStorage::AllocateSaveData(unsigned int uiBytes) -{ - return InternalStorageManager.m_SaveGame.AllocateSaveData(uiBytes); -} - -void C4JStorage::SetSaveImages(PBYTE pbThumbnail, DWORD dwThumbnailBytes, PBYTE pbImage, DWORD dwImageBytes, PBYTE pbTextData, DWORD dwTextDataBytes) -{ - InternalStorageManager.m_SaveGame.SetSaveImages(pbThumbnail, dwThumbnailBytes, pbImage, dwImageBytes, pbTextData, dwTextDataBytes); -} - -void C4JStorage::SetDefaultImages(PBYTE pbOptionsImage, DWORD dwOptionsImageBytes, PBYTE pbSaveImage, DWORD dwSaveImageBytes, PBYTE pbSaveThumbnail, DWORD dwSaveThumbnailBytes) -{ - InternalStorageManager.m_SaveGame.SetDefaultImages(pbOptionsImage, dwOptionsImageBytes, pbSaveImage, dwSaveImageBytes, pbSaveThumbnail, dwSaveThumbnailBytes); -} - -void C4JStorage::GetDefaultSaveImage(PBYTE *ppbSaveImage, DWORD *pdwSaveImageBytes) -{ - InternalStorageManager.m_SaveGame.GetDefaultSaveImage(ppbSaveImage, pdwSaveImageBytes); -} - -void C4JStorage::GetDefaultSaveThumbnail(PBYTE *ppbSaveThumbnail, DWORD *pdwSaveThumbnailBytes) -{ - InternalStorageManager.m_SaveGame.GetDefaultSaveThumbnail(ppbSaveThumbnail, pdwSaveThumbnailBytes); -} - -C4JStorage::ESaveGameState C4JStorage::SaveSaveData(int (*Func)(LPVOID, const bool), LPVOID lpParam) -{ - return InternalStorageManager.m_SaveGame.SaveSaveData(Func, lpParam); -} - -void C4JStorage::CopySaveDataToNewSave(PBYTE pbThumbnail, DWORD cbThumbnail, WCHAR *wchNewName, int (*Func)(LPVOID lpParam, bool), LPVOID lpParam) -{ - InternalStorageManager.m_SaveGame.CopySaveDataToNewSave(pbThumbnail, cbThumbnail, wchNewName, Func, lpParam); -} - -void C4JStorage::SetSaveDeviceSelected(unsigned int uiPad, bool bSelected) -{ - ; -} - -bool C4JStorage::GetSaveDeviceSelected(unsigned int iPad) -{ - return true; -} - -C4JStorage::ESaveGameState C4JStorage::DoesSaveExist(bool *pbExists) -{ - return InternalStorageManager.m_SaveGame.DoesSaveExist(pbExists); -} - -bool C4JStorage::EnoughSpaceForAMinSaveGame() -{ - return true; -} - -void C4JStorage::SetMaxSaves(int iMaxC) -{ - (void)iMaxC; -} - -void C4JStorage::SetIncompleteSaveCallback(void (*Func)(LPVOID, const ESaveIncompleteType, int blocksRequired), LPVOID param) -{ - - (void)Func; - (void)param; -} - -void C4JStorage::ContinueIncompleteOperation() -{ - -} - -C4JStorage::ESaveGameState C4JStorage::GetSaveState() -{ - return C4JStorage::ESaveGame_Idle; -} - -void C4JStorage::SetSaveMessageVPosition(float fY) -{ - ; -} - -C4JStorage::ESaveGameState C4JStorage::GetSavesInfo(int iPad, int (*Func)(LPVOID lpParam, SAVE_DETAILS *pSaveDetails, const bool), LPVOID lpParam, - char *pszSavePackName) -{ - return InternalStorageManager.m_SaveGame.GetSavesInfo(iPad, Func, lpParam, pszSavePackName); -} - -PSAVE_DETAILS C4JStorage::ReturnSavesInfo() -{ - return InternalStorageManager.m_SaveGame.ReturnSavesInfo(); -} - -void C4JStorage::ClearSavesInfo() -{ - InternalStorageManager.m_SaveGame.ClearSavesInfo(); -} - -C4JStorage::ESaveGameState C4JStorage::LoadSaveDataThumbnail(PSAVE_INFO pSaveInfo, - int (*Func)(LPVOID lpParam, PBYTE pbThumbnail, DWORD dwThumbnailBytes), LPVOID lpParam) -{ - return InternalStorageManager.m_SaveGame.LoadSaveDataThumbnail(pSaveInfo, Func, lpParam); -} - -void C4JStorage::GetSaveCacheFileInfo(DWORD dwFile, XCONTENT_DATA &xContentData) -{ - ; -} - -void C4JStorage::GetSaveCacheFileInfo(DWORD dwFile, PBYTE *ppbImageData, DWORD *pdwImageBytes) -{ - ; -} - -C4JStorage::ESaveGameState C4JStorage::LoadSaveData(PSAVE_INFO pSaveInfo, int (*Func)(LPVOID lpParam, const bool, const bool), LPVOID lpParam) -{ - return InternalStorageManager.m_SaveGame.LoadSaveData(pSaveInfo, Func, lpParam); -} - -C4JStorage::ESaveGameState C4JStorage::DeleteSaveData(PSAVE_INFO pSaveInfo, int (*Func)(LPVOID lpParam, const bool), LPVOID lpParam) -{ - return InternalStorageManager.m_SaveGame.DeleteSaveData(pSaveInfo, Func, lpParam); -} - -C4JStorage::ESaveGameState C4JStorage::RenameSaveData(int iRenameIndex, uint16_t *pui16NewName, int (*Func)(LPVOID lpParam, const bool), LPVOID lpParam) -{ - return InternalStorageManager.m_SaveGame.RenameSaveData(iRenameIndex, pui16NewName, Func, lpParam); -} - -void C4JStorage::RegisterMarketplaceCountsCallback(int (*Func)(LPVOID lpParam, C4JStorage::DLC_TMS_DETAILS *, int), LPVOID lpParam) -{ - ; -} - -void C4JStorage::SetDLCPackageRoot(char *pszDLCRoot) -{ - InternalStorageManager.m_DLC.SetPackageRoot(pszDLCRoot); -} - -C4JStorage::EDLCStatus C4JStorage::GetDLCOffers(int iPad, int (*Func)(LPVOID, int, DWORD, int), LPVOID lpParam, DWORD dwOfferTypesBitmask) -{ - return EDLC_Idle; -} - -DWORD C4JStorage::CancelGetDLCOffers() -{ - return 0; -} - -void C4JStorage::ClearDLCOffers() -{ - ; -} - -XMARKETPLACE_CONTENTOFFER_INFO &C4JStorage::GetOffer(DWORD dw) -{ - return InternalContentOfferInfo; -} - -int C4JStorage::GetOfferCount() -{ - return 0; -} - -DWORD C4JStorage::InstallOffer(int iOfferIDC, __uint64 *ullOfferIDA, int (*Func)(LPVOID, int, int), LPVOID lpParam, bool bTrial) -{ - return 0; -} - -DWORD C4JStorage::GetAvailableDLCCount(int iPad) -{ - return InternalStorageManager.m_DLC.GetAvailableDLCCount(iPad); -} - -C4JStorage::EDLCStatus C4JStorage::GetInstalledDLC(int iPad, int (*Func)(LPVOID, int, int), LPVOID lpParam) -{ - return InternalStorageManager.m_DLC.GetInstalledDLC(iPad, Func, lpParam); -} - -XCONTENT_DATA &C4JStorage::GetDLC(DWORD dw) -{ - return InternalStorageManager.m_DLC.GetDLC(dw); -} - -DWORD C4JStorage::MountInstalledDLC(int iPad, DWORD dwDLC, int (*Func)(LPVOID, int, DWORD, DWORD), LPVOID lpParam, LPCSTR szMountDrive) -{ - return InternalStorageManager.m_DLC.MountInstalledDLC(iPad, dwDLC, Func, lpParam, szMountDrive); -} - -DWORD C4JStorage::UnmountInstalledDLC(LPCSTR szMountDrive) -{ - return InternalStorageManager.m_DLC.UnmountInstalledDLC(szMountDrive); -} - -void C4JStorage::GetMountedDLCFileList(const char *szMountDrive, std::vector &fileList) -{ - InternalStorageManager.m_DLC.GetMountedDLCFileList(szMountDrive, fileList); -} - -std::string C4JStorage::GetMountedPath(std::string szMount) -{ - return InternalStorageManager.m_DLC.GetMountedPath(szMount); -} - -C4JStorage::ETMSStatus C4JStorage::ReadTMSFile(int iQuadrant, eGlobalStorage eStorageFacility, C4JStorage::eTMS_FileType eFileType, - WCHAR *pwchFilename, BYTE **ppBuffer, DWORD *pdwBufferSize, - int (*Func)(LPVOID, WCHAR *, int, bool, int), LPVOID lpParam, int iAction) -{ - return ETMSStatus_Idle; -} - -bool C4JStorage::WriteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility, WCHAR *pwchFilename, BYTE *pBuffer, DWORD dwBufferSize) -{ - return true; -} - -bool C4JStorage::DeleteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility, WCHAR *pwchFilename) -{ - return true; -} - -void C4JStorage::StoreTMSPathName(WCHAR *pwchName) -{ - ; -} - -C4JStorage::ETMSStatus C4JStorage::TMSPP_ReadFile(int iPad, C4JStorage::eGlobalStorage eStorageFacility, C4JStorage::eTMS_FILETYPEVAL eFileTypeVal, - LPCSTR szFilename, int (*Func)(LPVOID, int, int, PTMSPP_FILEDATA, LPCSTR), LPVOID lpParam, - int iUserData) -{ - return ETMSStatus_Idle; -} - -unsigned int C4JStorage::CRC(unsigned char *buf, int len) -{ - return 0; -} diff --git a/Minecraft.Client/4JLibs-master/Windows_Libs/Dev/Storage/STO_SaveGame.cpp b/Minecraft.Client/4JLibs-master/Windows_Libs/Dev/Storage/STO_SaveGame.cpp deleted file mode 100644 index 40c7383..0000000 --- a/Minecraft.Client/4JLibs-master/Windows_Libs/Dev/Storage/STO_SaveGame.cpp +++ /dev/null @@ -1,808 +0,0 @@ -/* -MIT License - -Copyright (c) 2026 Patoke - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#include "STO_SaveGame.h" -#include - -static unsigned long s_pngCrcTable[256]; -static bool s_pngCrcTableReady = false; - -static void BuildPngCrcTable() -{ - for (unsigned int n = 0; n < 256; n++) - { - unsigned long c = n; - for (int k = 0; k < 8; k++) - c = (c & 1) ? (0xEDB88320L ^ (c >> 1)) : (c >> 1); - s_pngCrcTable[n] = c; - } - s_pngCrcTableReady = true; -} - -static unsigned long PngCrc32(const unsigned char *buf, unsigned int len) -{ - if (!s_pngCrcTableReady) BuildPngCrcTable(); - unsigned long c = 0xFFFFFFFFL; - for (unsigned int i = 0; i < len; i++) - c = s_pngCrcTable[(c ^ buf[i]) & 0xFF] ^ (c >> 8); - return c ^ 0xFFFFFFFFL; -} - -static inline unsigned int WriteBE32(unsigned int v) -{ - return ((v >> 24) & 0xFF) | - ((v >> 8) & 0xFF00) | - ((v << 8) & 0xFF0000) | - ((v << 24) & 0xFF000000); -} - -static void GetGameHDDPath(char *outPath, int maxLen) -{ - char curDir[256]; - GetCurrentDirectoryA(sizeof(curDir), curDir); - sprintf_s(outPath, maxLen, "%s\\Windows64\\GameHDD", curDir); -} - -CSaveGame::CSaveGame() -{ - m_pSaveData = nullptr; - m_uiSaveSize = 0; - m_bIsSafeDisabled = false; - - ZeroMemory(m_szSaveUniqueName, sizeof(m_szSaveUniqueName)); - ZeroMemory(m_wszSaveTitle, sizeof(m_wszSaveTitle)); - - m_pSaveDetails = nullptr; - m_bHasSaveDetails = false; - - m_pbThumbnail = nullptr; - m_dwThumbnailBytes = 0; - m_pbDefaultThumbnail = nullptr; - m_dwDefaultThumbnailBytes = 0; - m_pbDefaultSaveImage = nullptr; - m_dwDefaultSaveImageBytes = 0; - - char gameHDDPath[256]; - GetGameHDDPath(gameHDDPath, sizeof(gameHDDPath)); - - char win64Path[256]; - char curDir[256]; - GetCurrentDirectoryA(sizeof(curDir), curDir); - sprintf_s(win64Path, sizeof(win64Path), "%s\\Windows64", curDir); - CreateDirectoryA(win64Path, 0); - CreateDirectoryA(gameHDDPath, 0); -} - -void CSaveGame::SetSaveDisabled(bool bDisable) -{ - m_bIsSafeDisabled = bDisable; -} - -bool CSaveGame::GetSaveDisabled(void) -{ - return m_bIsSafeDisabled; -} - -void CSaveGame::ResetSaveData() -{ - free(m_pSaveData); - m_pSaveData = nullptr; - m_uiSaveSize = 0; -} - -C4JStorage::ESaveGameState CSaveGame::GetSavesInfo(int iPad, int (*Func)(LPVOID lpParam, SAVE_DETAILS *pSaveDetails, const bool), LPVOID lpParam, - char *pszSavePackName) -{ - WIN32_FIND_DATAA findFileData; - WIN32_FILE_ATTRIBUTE_DATA fileInfoBuffer; - - if (!m_pSaveDetails) - { - m_pSaveDetails = new SAVE_DETAILS(); - memset(m_pSaveDetails, 0, sizeof(SAVE_DETAILS)); - } - - delete[] m_pSaveDetails->SaveInfoA; - m_pSaveDetails->SaveInfoA = nullptr; - m_pSaveDetails->iSaveC = 0; - - char gameHDDPath[256]; - GetGameHDDPath(gameHDDPath, sizeof(gameHDDPath)); - - char searchPattern[280]; - sprintf_s(searchPattern, sizeof(searchPattern), "%s\\*", gameHDDPath); - - int resultCount = 0; - HANDLE h = FindFirstFileExA(searchPattern, FindExInfoStandard, &findFileData, FindExSearchLimitToDirectories, 0, 0); - if (h == INVALID_HANDLE_VALUE) - { - DWORD error = GetLastError(); - printf("Error finding save dirs: 0x%08x\n", error); - } - else - { - do - { - if ((findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0 && - strcmp(findFileData.cFileName, ".") != 0 && - strcmp(findFileData.cFileName, "..") != 0) - { - char saveFilePath[512]; - sprintf_s(saveFilePath, sizeof(saveFilePath), "%s\\%s\\saveData.ms", gameHDDPath, findFileData.cFileName); - if (GetFileAttributesA(saveFilePath) != INVALID_FILE_ATTRIBUTES) - { - resultCount++; - } - } - } while (FindNextFileA(h, &findFileData)); - FindClose(h); - } - - if (resultCount > 0) - { - m_pSaveDetails->SaveInfoA = new SAVE_INFO[resultCount]; - memset(m_pSaveDetails->SaveInfoA, 0, sizeof(SAVE_INFO) * resultCount); - - m_pSaveDetails->iSaveC = 0; - int i = 0; - HANDLE fi = FindFirstFileExA(searchPattern, FindExInfoStandard, &findFileData, FindExSearchLimitToDirectories, 0, 0); - if (fi != INVALID_HANDLE_VALUE) - { - do - { - if ((findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0 && - strcmp(findFileData.cFileName, ".") != 0 && - strcmp(findFileData.cFileName, "..") != 0) - { - char saveFilePath[512]; - sprintf_s(saveFilePath, sizeof(saveFilePath), "%s\\%s\\saveData.ms", gameHDDPath, findFileData.cFileName); - - if (GetFileAttributesA(saveFilePath) == INVALID_FILE_ATTRIBUTES) - continue; - - strcpy_s(m_pSaveDetails->SaveInfoA[i].UTF8SaveFilename, findFileData.cFileName); - - char saveDirPath[512]; - sprintf_s(saveDirPath, sizeof(saveDirPath), "%s\\%s", gameHDDPath, findFileData.cFileName); - - char titleBuf[MAX_DISPLAYNAME_LENGTH]; - if (LoadTitleFromFile(saveDirPath, titleBuf, sizeof(titleBuf))) - { - strcpy_s(m_pSaveDetails->SaveInfoA[i].UTF8SaveTitle, titleBuf); - } - else - { - // fallback: use the folder name as the display title - strcpy_s(m_pSaveDetails->SaveInfoA[i].UTF8SaveTitle, findFileData.cFileName); - } - - GetFileAttributesExA(saveFilePath, GetFileExInfoStandard, &fileInfoBuffer); - m_pSaveDetails->SaveInfoA[i].metaData.dataSize = fileInfoBuffer.nFileSizeLow; - - char thumbFilePath[512]; - sprintf_s(thumbFilePath, sizeof(thumbFilePath), "%s\\%s\\saveThumbnail.png", gameHDDPath, findFileData.cFileName); - WIN32_FILE_ATTRIBUTE_DATA thumbInfo; - if (GetFileAttributesExA(thumbFilePath, GetFileExInfoStandard, &thumbInfo)) - { - m_pSaveDetails->SaveInfoA[i].metaData.thumbnailSize = thumbInfo.nFileSizeLow; - } - - FILETIME ft = fileInfoBuffer.ftLastWriteTime; - ULARGE_INTEGER ull; - ull.LowPart = ft.dwLowDateTime; - ull.HighPart = ft.dwHighDateTime; - - m_pSaveDetails->SaveInfoA[i].metaData.modifiedTime = (time_t)((ull.QuadPart - 116444736000000000ULL) / 10000000ULL); - - i++; - m_pSaveDetails->iSaveC++; - } - } while (FindNextFileA(fi, &findFileData)); - FindClose(fi); - } - } - - m_bHasSaveDetails = true; - if (Func) - { - Func(lpParam, m_pSaveDetails, true); - } - - return C4JStorage::ESaveGame_Idle; -} - -PSAVE_DETAILS CSaveGame::ReturnSavesInfo() -{ - if (m_bHasSaveDetails) - return m_pSaveDetails; - else - return nullptr; -} - -void CSaveGame::ClearSavesInfo() -{ - m_bHasSaveDetails = false; - if (m_pSaveDetails) - { - if (m_pSaveDetails->SaveInfoA) - { - delete[] m_pSaveDetails->SaveInfoA; - m_pSaveDetails->SaveInfoA = nullptr; - m_pSaveDetails->iSaveC = 0; - } - delete m_pSaveDetails; - m_pSaveDetails = 0; - } -} - -C4JStorage::ESaveGameState CSaveGame::LoadSaveDataThumbnail(PSAVE_INFO pSaveInfo, - int (*Func)(LPVOID lpParam, PBYTE pbThumbnail, DWORD dwThumbnailBytes), LPVOID lpParam) -{ - PBYTE pbThumbnail = nullptr; - DWORD dwThumbnailBytes = 0; - - char gameHDDPath[256]; - GetGameHDDPath(gameHDDPath, sizeof(gameHDDPath)); - - char thumbPath[512]; - sprintf_s(thumbPath, sizeof(thumbPath), "%s\\%s\\saveThumbnail.png", gameHDDPath, pSaveInfo->UTF8SaveFilename); - - HANDLE h = CreateFileA(thumbPath, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); - if (h != INVALID_HANDLE_VALUE) - { - DWORD fileSize = GetFileSize(h, NULL); - if (fileSize != 0 && fileSize != INVALID_FILE_SIZE) - { - pbThumbnail = (PBYTE)malloc(fileSize); - if (pbThumbnail) - { - DWORD bytesRead = 0; - if (ReadFile(h, pbThumbnail, fileSize, &bytesRead, 0) && bytesRead == fileSize) - { - dwThumbnailBytes = fileSize; - } - else - { - free(pbThumbnail); - pbThumbnail = nullptr; - } - } - } - CloseHandle(h); - } - - Func(lpParam, pbThumbnail, dwThumbnailBytes); - - if (pbThumbnail) - { - free(pbThumbnail); - } - - return C4JStorage::ESaveGame_GetSaveThumbnail; -} - -C4JStorage::ESaveGameState CSaveGame::LoadSaveData(PSAVE_INFO pSaveInfo, int (*Func)(LPVOID lpParam, const bool, const bool), LPVOID lpParam) -{ - SetSaveUniqueFilename(pSaveInfo->UTF8SaveFilename); - - if (m_pSaveData) - { - free(m_pSaveData); - m_pSaveData = nullptr; - } - - char gameHDDPath[256]; - GetGameHDDPath(gameHDDPath, sizeof(gameHDDPath)); - - char saveDirPath[512]; - sprintf_s(saveDirPath, sizeof(saveDirPath), "%s\\%s", gameHDDPath, m_szSaveUniqueName); - - char titleBuf[MAX_DISPLAYNAME_LENGTH]; - if (LoadTitleFromFile(saveDirPath, titleBuf, sizeof(titleBuf))) - { - MultiByteToWideChar(CP_UTF8, 0, titleBuf, -1, m_wszSaveTitle, MAX_DISPLAYNAME_LENGTH); - } - - char fileName[512]; - sprintf_s(fileName, sizeof(fileName), "%s\\saveData.ms", saveDirPath); - - WIN32_FILE_ATTRIBUTE_DATA fileInfo; - if (!GetFileAttributesExA(fileName, GetFileExInfoStandard, &fileInfo)) - { - if (Func) Func(lpParam, 0, false); - return C4JStorage::ESaveGame_Idle; - } - - m_uiSaveSize = fileInfo.nFileSizeLow; - m_pSaveData = malloc(m_uiSaveSize); - - HANDLE h = CreateFileA(fileName, GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); - - bool success = false; - if (h != INVALID_HANDLE_VALUE) - { - DWORD bytesRead = 0; - BOOL res = ReadFile(h, m_pSaveData, m_uiSaveSize, &bytesRead, 0); - _ASSERT(res && bytesRead == m_uiSaveSize); - CloseHandle(h); - success = (res && bytesRead == m_uiSaveSize); - } - - if (!success && m_pSaveData) - { - free(m_pSaveData); - m_pSaveData = nullptr; - m_uiSaveSize = 0; - } - - if (Func) - { - Func(lpParam, 0, success); - } - - return C4JStorage::ESaveGame_Idle; -} - -unsigned int CSaveGame::GetSaveSize() -{ - return m_uiSaveSize; -} - -void CSaveGame::GetSaveData(void *pvData, unsigned int *puiBytes) -{ - if (pvData) - { - memmove(pvData, m_pSaveData, m_uiSaveSize); - *puiBytes = m_uiSaveSize; - } - else - { - *puiBytes = 0; - } -} - -bool CSaveGame::GetSaveUniqueNumber(INT *piVal) -{ - *piVal = 0; - - if (m_szSaveUniqueName[0] != '\0') - { - *piVal = atoi(m_szSaveUniqueName); - return true; - } - return false; -} - -bool CSaveGame::GetSaveUniqueFilename(char *pszName) -{ - if (m_szSaveUniqueName[0] != '\0') - { - strcpy_s(pszName, MAX_SAVEFILENAME_LENGTH, m_szSaveUniqueName); - return true; - } - return false; -} - -void CSaveGame::SetSaveTitle(LPCWSTR pwchDefaultSaveName) -{ - if (m_szSaveUniqueName[0] == '\0') - { - CreateSaveUniqueName(); - } - wcscpy_s(m_wszSaveTitle, MAX_DISPLAYNAME_LENGTH, pwchDefaultSaveName); -} - -LPCWSTR CSaveGame::GetSaveTitle() -{ - return m_wszSaveTitle; -} - -PVOID CSaveGame::AllocateSaveData(unsigned int uiBytes) -{ - free(m_pSaveData); - - m_pSaveData = malloc(uiBytes); - if (m_pSaveData) - { - m_uiSaveSize = uiBytes; - } - - return m_pSaveData; -} - -// https://github.com/LCEMP/LCEMP -void CSaveGame::SetSaveImages(PBYTE pbThumbnail, DWORD dwThumbnailBytes, PBYTE pbImage, DWORD dwImageBytes, PBYTE pbTextData, DWORD dwTextDataBytes) -{ - if (m_pbThumbnail) - { - free(m_pbThumbnail); - m_pbThumbnail = nullptr; - m_dwThumbnailBytes = 0; - } - - - if (pbThumbnail && dwThumbnailBytes > 0) - { - const DWORD kInsertOffset = 33; // end of PNG sig + IHDR - - if (pbTextData && dwTextDataBytes > 0 && dwThumbnailBytes > kInsertOffset) - { - const DWORD chunkOverhead = 4 + 4 + 4; - const DWORD chunkTotal = chunkOverhead + dwTextDataBytes; - const DWORD newSize = dwThumbnailBytes + chunkTotal; - - m_pbThumbnail = (PBYTE)malloc(newSize); - if (m_pbThumbnail) - { - memcpy(m_pbThumbnail, pbThumbnail, kInsertOffset); - - PBYTE p = m_pbThumbnail + kInsertOffset; - - *(unsigned int *)p = WriteBE32(dwTextDataBytes); - p += 4; - - p[0] = 't'; p[1] = 'E'; p[2] = 'X'; p[3] = 't'; - p += 4; - - memcpy(p, pbTextData, dwTextDataBytes); - p += dwTextDataBytes; - - unsigned long crc = PngCrc32(m_pbThumbnail + kInsertOffset + 4, - 4 + dwTextDataBytes); - *(unsigned int *)p = WriteBE32((unsigned int)crc); - - memcpy(m_pbThumbnail + kInsertOffset + chunkTotal, - pbThumbnail + kInsertOffset, - dwThumbnailBytes - kInsertOffset); - - m_dwThumbnailBytes = newSize; - } - } - else - { - m_pbThumbnail = (PBYTE)malloc(dwThumbnailBytes); - if (m_pbThumbnail) - { - memcpy(m_pbThumbnail, pbThumbnail, dwThumbnailBytes); - m_dwThumbnailBytes = dwThumbnailBytes; - } - } - } -} - -// https://github.com/LCEMP/LCEMP -C4JStorage::ESaveGameState CSaveGame::SaveSaveData(int (*Func)(LPVOID, const bool), LPVOID lpParam) -{ - if (!m_pSaveData || m_uiSaveSize == 0) - { - if (Func) Func(lpParam, false); - return C4JStorage::ESaveGame_Idle; - } - - char gameHDDPath[256]; - GetGameHDDPath(gameHDDPath, sizeof(gameHDDPath)); - - char saveDirPath[512]; - sprintf_s(saveDirPath, sizeof(saveDirPath), "%s\\%s", gameHDDPath, m_szSaveUniqueName); - CreateDirectoryA(saveDirPath, 0); - - char saveFilePath[512]; - sprintf_s(saveFilePath, sizeof(saveFilePath), "%s\\saveData.ms", saveDirPath); - - HANDLE h = CreateFileA(saveFilePath, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); - if (h == INVALID_HANDLE_VALUE) - { - if (Func) Func(lpParam, false); - return C4JStorage::ESaveGame_Idle; - } - - DWORD bytesWritten = 0; - BOOL res = WriteFile(h, m_pSaveData, m_uiSaveSize, &bytesWritten, 0); - CloseHandle(h); - - - SaveTitleFile(saveDirPath); - - - if (m_pbThumbnail && m_dwThumbnailBytes > 0) - { - char thumbPath[512]; - sprintf_s(thumbPath, sizeof(thumbPath), "%s\\saveThumbnail.png", saveDirPath); - - HANDLE hThumb = CreateFileA(thumbPath, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); - if (hThumb != INVALID_HANDLE_VALUE) - { - DWORD thumbWritten = 0; - WriteFile(hThumb, m_pbThumbnail, m_dwThumbnailBytes, &thumbWritten, 0); - CloseHandle(hThumb); - } - - - free(m_pbThumbnail); - m_pbThumbnail = nullptr; - m_dwThumbnailBytes = 0; - } - - bool success = (res && bytesWritten == m_uiSaveSize); - if (Func) Func(lpParam, success); - - return C4JStorage::ESaveGame_Idle; -} - -C4JStorage::ESaveGameState CSaveGame::DeleteSaveData(PSAVE_INFO pSaveInfo, int (*Func)(LPVOID lpParam, const bool), LPVOID lpParam) -{ - char gameHDDPath[256]; - GetGameHDDPath(gameHDDPath, sizeof(gameHDDPath)); - - char saveDirPath[512]; - sprintf_s(saveDirPath, sizeof(saveDirPath), "%s\\%s", gameHDDPath, pSaveInfo->UTF8SaveFilename); - - char searchPattern[512]; - sprintf_s(searchPattern, sizeof(searchPattern), "%s\\*", saveDirPath); - - WIN32_FIND_DATAA findData; - HANDLE hFind = FindFirstFileA(searchPattern, &findData); - if (hFind != INVALID_HANDLE_VALUE) - { - do - { - if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) - { - char filePath[512]; - sprintf_s(filePath, sizeof(filePath), "%s\\%s", saveDirPath, findData.cFileName); - DeleteFileA(filePath); - } - } while (FindNextFileA(hFind, &findData)); - FindClose(hFind); - } - - RemoveDirectoryA(saveDirPath); - - bool success = (GetFileAttributesA(saveDirPath) == INVALID_FILE_ATTRIBUTES); - - if (Func) Func(lpParam, success); - - return C4JStorage::ESaveGame_Idle; -} - -C4JStorage::ESaveGameState CSaveGame::DoesSaveExist(bool *pbExists) -{ - if (m_szSaveUniqueName[0] == '\0') - { - *pbExists = false; - return C4JStorage::ESaveGame_Idle; - } - - char gameHDDPath[256]; - GetGameHDDPath(gameHDDPath, sizeof(gameHDDPath)); - - char saveFilePath[512]; - sprintf_s(saveFilePath, sizeof(saveFilePath), "%s\\%s\\saveData.ms", gameHDDPath, m_szSaveUniqueName); - - *pbExists = (GetFileAttributesA(saveFilePath) != INVALID_FILE_ATTRIBUTES); - return C4JStorage::ESaveGame_Idle; -} - -void CSaveGame::CopySaveDataToNewSave(PBYTE pbThumbnail, DWORD cbThumbnail, WCHAR *wchNewName, int (*Func)(LPVOID lpParam, bool), LPVOID lpParam) -{ - char oldUniqueName[32]; - strcpy_s(oldUniqueName, m_szSaveUniqueName); - - CreateSaveUniqueName(); - - char gameHDDPath[256]; - GetGameHDDPath(gameHDDPath, sizeof(gameHDDPath)); - - char newSaveDirPath[512]; - sprintf_s(newSaveDirPath, sizeof(newSaveDirPath), "%s\\%s", gameHDDPath, m_szSaveUniqueName); - CreateDirectoryA(newSaveDirPath, 0); - - char oldSaveFile[512], newSaveFile[512]; - sprintf_s(oldSaveFile, sizeof(oldSaveFile), "%s\\%s\\saveData.ms", gameHDDPath, oldUniqueName); - sprintf_s(newSaveFile, sizeof(newSaveFile), "%s\\saveData.ms", newSaveDirPath); - CopyFileA(oldSaveFile, newSaveFile, FALSE); - - char oldThumbFile[512], newThumbFile[512]; - sprintf_s(oldThumbFile, sizeof(oldThumbFile), "%s\\%s\\saveThumbnail.png", gameHDDPath, oldUniqueName); - sprintf_s(newThumbFile, sizeof(newThumbFile), "%s\\saveThumbnail.png", newSaveDirPath); - CopyFileA(oldThumbFile, newThumbFile, FALSE); - - if (pbThumbnail && cbThumbnail > 0) - { - HANDLE hThumb = CreateFileA(newThumbFile, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); - if (hThumb != INVALID_HANDLE_VALUE) - { - DWORD thumbWritten = 0; - WriteFile(hThumb, pbThumbnail, cbThumbnail, &thumbWritten, 0); - CloseHandle(hThumb); - } - } - - if (wchNewName) - { - wcscpy_s(m_wszSaveTitle, MAX_DISPLAYNAME_LENGTH, wchNewName); - } - SaveTitleFile(newSaveDirPath); - - bool success = (GetFileAttributesA(newSaveFile) != INVALID_FILE_ATTRIBUTES); - if (Func) Func(lpParam, success); -} - -void CSaveGame::SetSaveUniqueFilename(char *szFilename) -{ - strcpy_s(m_szSaveUniqueName, szFilename); -} - -void CSaveGame::CreateSaveUniqueName(void) -{ - _SYSTEMTIME UTCSysTime; - GetSystemTime(&UTCSysTime); - - sprintf_s(m_szSaveUniqueName, sizeof(m_szSaveUniqueName), "%4d%02d%02d%02d%02d%02d", UTCSysTime.wYear, UTCSysTime.wMonth, UTCSysTime.wDay, - UTCSysTime.wHour, UTCSysTime.wMinute, UTCSysTime.wSecond); -} - -void CSaveGame::SaveTitleFile(const char *saveDirPath) -{ - if (m_wszSaveTitle[0] == L'\0') - return; - - char titleFilePath[512]; - sprintf_s(titleFilePath, sizeof(titleFilePath), "%s\\saveTitle.txt", saveDirPath); - - char utf8Title[MAX_DISPLAYNAME_LENGTH * 3]; - int len = WideCharToMultiByte(CP_UTF8, 0, m_wszSaveTitle, -1, utf8Title, sizeof(utf8Title), NULL, NULL); - - if (len > 0) - { - HANDLE h = CreateFileA(titleFilePath, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); - if (h != INVALID_HANDLE_VALUE) - { - DWORD bytesWritten = 0; - WriteFile(h, utf8Title, len - 1, &bytesWritten, 0); // don't write null terminator - CloseHandle(h); - } - } -} - -bool CSaveGame::LoadTitleFromFile(const char *saveDirPath, char *outUTF8Title, int maxLen) -{ - char titleFilePath[512]; - sprintf_s(titleFilePath, sizeof(titleFilePath), "%s\\saveTitle.txt", saveDirPath); - - HANDLE h = CreateFileA(titleFilePath, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); - if (h == INVALID_HANDLE_VALUE) - return false; - - DWORD fileSize = GetFileSize(h, NULL); - if (fileSize == 0 || fileSize == INVALID_FILE_SIZE || fileSize >= (DWORD)maxLen) - { - CloseHandle(h); - return false; - } - - DWORD bytesRead = 0; - ReadFile(h, outUTF8Title, fileSize, &bytesRead, 0); - CloseHandle(h); - - if (bytesRead > 0) - { - outUTF8Title[bytesRead] = '\0'; - return true; - } - return false; -} - -void CSaveGame::SetDefaultImages(PBYTE pbOptionsImage, DWORD dwOptionsImageBytes, PBYTE pbSaveImage, DWORD dwSaveImageBytes, PBYTE pbSaveThumbnail, DWORD dwSaveThumbnailBytes) -{ - if (m_pbDefaultSaveImage) - { - free(m_pbDefaultSaveImage); - m_pbDefaultSaveImage = nullptr; - m_dwDefaultSaveImageBytes = 0; - } - if (pbSaveImage && dwSaveImageBytes > 0) - { - m_pbDefaultSaveImage = (PBYTE)malloc(dwSaveImageBytes); - if (m_pbDefaultSaveImage) - { - memcpy(m_pbDefaultSaveImage, pbSaveImage, dwSaveImageBytes); - m_dwDefaultSaveImageBytes = dwSaveImageBytes; - } - } - - if (m_pbDefaultThumbnail) - { - free(m_pbDefaultThumbnail); - m_pbDefaultThumbnail = nullptr; - m_dwDefaultThumbnailBytes = 0; - } - if (pbSaveThumbnail && dwSaveThumbnailBytes > 0) - { - m_pbDefaultThumbnail = (PBYTE)malloc(dwSaveThumbnailBytes); - if (m_pbDefaultThumbnail) - { - memcpy(m_pbDefaultThumbnail, pbSaveThumbnail, dwSaveThumbnailBytes); - m_dwDefaultThumbnailBytes = dwSaveThumbnailBytes; - } - } -} - -void CSaveGame::GetDefaultSaveImage(PBYTE *ppbSaveImage, DWORD *pdwSaveImageBytes) -{ - if (ppbSaveImage) *ppbSaveImage = m_pbDefaultSaveImage; - if (pdwSaveImageBytes) *pdwSaveImageBytes = m_dwDefaultSaveImageBytes; -} - -void CSaveGame::GetDefaultSaveThumbnail(PBYTE *ppbSaveThumbnail, DWORD *pdwSaveThumbnailBytes) -{ - if (ppbSaveThumbnail) *ppbSaveThumbnail = m_pbDefaultThumbnail; - if (pdwSaveThumbnailBytes) *pdwSaveThumbnailBytes = m_dwDefaultThumbnailBytes; -} - -C4JStorage::ESaveGameState CSaveGame::RenameSaveData(int iRenameIndex, uint16_t *pui16NewName, int (*Func)(LPVOID lpParam, const bool), LPVOID lpParam) -{ - bool bSuccess = false; - - if (m_pSaveDetails && iRenameIndex >= 0 && iRenameIndex < m_pSaveDetails->iSaveC && pui16NewName) - { - char gameHDDPath[256]; - GetGameHDDPath(gameHDDPath, sizeof(gameHDDPath)); - - char saveDirPath[512]; - sprintf_s(saveDirPath, sizeof(saveDirPath), "%s\\%s", gameHDDPath, m_pSaveDetails->SaveInfoA[iRenameIndex].UTF8SaveFilename); - - wchar_t newTitle[MAX_DISPLAYNAME_LENGTH]; - int i = 0; - while (i < MAX_DISPLAYNAME_LENGTH - 1 && pui16NewName[i] != 0) - { - newTitle[i] = (wchar_t)pui16NewName[i]; - i++; - } - newTitle[i] = L'\0'; - - char titleFilePath[512]; - sprintf_s(titleFilePath, sizeof(titleFilePath), "%s\\saveTitle.txt", saveDirPath); - - char utf8Title[MAX_DISPLAYNAME_LENGTH * 3]; - int len = WideCharToMultiByte(CP_UTF8, 0, newTitle, -1, utf8Title, sizeof(utf8Title), NULL, NULL); - - if (len > 0) - { - HANDLE h = CreateFileA(titleFilePath, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); - if (h != INVALID_HANDLE_VALUE) - { - DWORD bytesWritten = 0; - WriteFile(h, utf8Title, len - 1, &bytesWritten, 0); - CloseHandle(h); - - WideCharToMultiByte(CP_UTF8, 0, newTitle, -1, m_pSaveDetails->SaveInfoA[iRenameIndex].UTF8SaveTitle, MAX_DISPLAYNAME_LENGTH, NULL, NULL); - bSuccess = true; - } - } - } - - if (Func) Func(lpParam, bSuccess); - return C4JStorage::ESaveGame_Rename; -} diff --git a/Minecraft.Client/Windows_Libs/Dev/Storage/STO_SaveGame.cpp b/Minecraft.Client/Windows_Libs/Dev/Storage/STO_SaveGame.cpp index defe69f..56f58ff 100644 --- a/Minecraft.Client/Windows_Libs/Dev/Storage/STO_SaveGame.cpp +++ b/Minecraft.Client/Windows_Libs/Dev/Storage/STO_SaveGame.cpp @@ -437,6 +437,7 @@ PVOID CSaveGame::AllocateSaveData(unsigned int uiBytes) return m_pSaveData; } +// https://github.com/LCEMP/LCEMP void CSaveGame::SetSaveImages(PBYTE pbThumbnail, DWORD dwThumbnailBytes, PBYTE pbImage, DWORD dwImageBytes, PBYTE pbTextData, DWORD dwTextDataBytes) { if (m_pbThumbnail) @@ -496,6 +497,7 @@ void CSaveGame::SetSaveImages(PBYTE pbThumbnail, DWORD dwThumbnailBytes, PBYTE p } } +// https://github.com/LCEMP/LCEMP C4JStorage::ESaveGameState CSaveGame::SaveSaveData(int (*Func)(LPVOID, const bool), LPVOID lpParam) { if (!m_pSaveData || m_uiSaveSize == 0)