diff --git a/CMakeLists.txt b/CMakeLists.txt index 853ef904..0a7f85b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required (VERSION 3.20) include($ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake) set(SWA_THIRDPARTY_ROOT ${CMAKE_SOURCE_DIR}/thirdparty) set(SWA_TOOLS_ROOT ${CMAKE_SOURCE_DIR}/tools) -set(CMAKE_CXX_STANDARD 23) +set(CMAKE_CXX_STANDARD 20) set(BUILD_SHARED_LIBS OFF) # Enable Hot Reload for MSVC compilers if supported. diff --git a/UnleashedRecomp/CMakeLists.txt b/UnleashedRecomp/CMakeLists.txt index 90f39a8c..9a89a0d7 100644 --- a/UnleashedRecomp/CMakeLists.txt +++ b/UnleashedRecomp/CMakeLists.txt @@ -226,6 +226,7 @@ find_package(magic_enum CONFIG REQUIRED) find_package(unofficial-tiny-aes-c CONFIG REQUIRED) find_package(nfd CONFIG REQUIRED) find_package(Vorbis CONFIG REQUIRED) +find_package(fmt CONFIG REQUIRED) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/D3D12) add_custom_command(TARGET UnleashedRecomp POST_BUILD @@ -266,6 +267,7 @@ target_link_libraries(UnleashedRecomp PRIVATE nfd::nfd msdf-atlas-gen::msdf-atlas-gen Vorbis::vorbisfile + fmt::fmt ) target_include_directories(UnleashedRecomp PRIVATE diff --git a/UnleashedRecomp/api/Hedgehog/Base/Type/detail/hhStringHolder.inl b/UnleashedRecomp/api/Hedgehog/Base/Type/detail/hhStringHolder.inl index 5fede682..5bd47552 100644 --- a/UnleashedRecomp/api/Hedgehog/Base/Type/detail/hhStringHolder.inl +++ b/UnleashedRecomp/api/Hedgehog/Base/Type/detail/hhStringHolder.inl @@ -48,7 +48,7 @@ namespace Hedgehog::Base do { originalValue = RefCountAndLength.value; - incrementedValue = std::byteswap(std::byteswap(originalValue) + 1); + incrementedValue = ByteSwap(ByteSwap(originalValue) + 1); } while (InterlockedCompareExchange(reinterpret_cast(&RefCountAndLength), incrementedValue, originalValue) != originalValue); } @@ -58,7 +58,7 @@ namespace Hedgehog::Base do { originalValue = RefCountAndLength.value; - decrementedValue = std::byteswap(std::byteswap(originalValue) - 1); + decrementedValue = ByteSwap(ByteSwap(originalValue) - 1); } while (InterlockedCompareExchange(reinterpret_cast(&RefCountAndLength), decrementedValue, originalValue) != originalValue); if (RefCountAndLength == 0) diff --git a/UnleashedRecomp/api/boost/smart_ptr/shared_ptr.h b/UnleashedRecomp/api/boost/smart_ptr/shared_ptr.h index 55043597..adec62eb 100644 --- a/UnleashedRecomp/api/boost/smart_ptr/shared_ptr.h +++ b/UnleashedRecomp/api/boost/smart_ptr/shared_ptr.h @@ -69,7 +69,7 @@ namespace boost uint32_t use_count() const { - return std::byteswap(static_cast(use_count_.value)); + return ByteSwap(static_cast(use_count_.value)); } bool unique() const diff --git a/UnleashedRecomp/apu/audio.cpp b/UnleashedRecomp/apu/audio.cpp index 76dac7cc..582231a9 100644 --- a/UnleashedRecomp/apu/audio.cpp +++ b/UnleashedRecomp/apu/audio.cpp @@ -38,7 +38,7 @@ uint32_t XAudioSubmitRenderDriverFrame(uint32_t driver, void* samples) { for (size_t j = 0; j < XAUDIO_NUM_CHANNELS; j++) { - xaudioSamplesBuffer[i * XAUDIO_NUM_CHANNELS + j] = std::byteswap(((uint32_t *)samples)[j * XAUDIO_NUM_SAMPLES + i]); + xaudioSamplesBuffer[i * XAUDIO_NUM_CHANNELS + j] = ByteSwap(((uint32_t *)samples)[j * XAUDIO_NUM_SAMPLES + i]); } } diff --git a/UnleashedRecomp/apu/driver/miniaudio_driver.cpp b/UnleashedRecomp/apu/driver/miniaudio_driver.cpp index 5b806fd5..8ac823d3 100644 --- a/UnleashedRecomp/apu/driver/miniaudio_driver.cpp +++ b/UnleashedRecomp/apu/driver/miniaudio_driver.cpp @@ -48,6 +48,6 @@ void XAudioSubmitFrame(void* samples) for (size_t i = 0; i < XAUDIO_NUM_SAMPLES; i++) { for (size_t j = 0; j < XAUDIO_NUM_CHANNELS; j++) - g_audioOutput[i * XAUDIO_NUM_CHANNELS + j] = std::byteswap(((uint32_t*)samples)[j * XAUDIO_NUM_SAMPLES + i]); + g_audioOutput[i * XAUDIO_NUM_CHANNELS + j] = ByteSwap(((uint32_t*)samples)[j * XAUDIO_NUM_SAMPLES + i]); } } diff --git a/UnleashedRecomp/apu/driver/xaudio_driver.cpp b/UnleashedRecomp/apu/driver/xaudio_driver.cpp index 2e4e58e1..2e59a9ef 100644 --- a/UnleashedRecomp/apu/driver/xaudio_driver.cpp +++ b/UnleashedRecomp/apu/driver/xaudio_driver.cpp @@ -111,7 +111,7 @@ void XAudioSubmitFrame(void* samples) for (size_t i = 0; i < XAUDIO_NUM_SAMPLES; i++) { for (size_t j = 0; j < 6; j++) - audioFrame[i * XAUDIO_NUM_CHANNELS + j] = std::byteswap(((uint32_t*)samples)[j * XAUDIO_NUM_SAMPLES + i]); + audioFrame[i * XAUDIO_NUM_CHANNELS + j] = ByteSwap(((uint32_t*)samples)[j * XAUDIO_NUM_SAMPLES + i]); } XAUDIO2_BUFFER buffer{}; diff --git a/UnleashedRecomp/cpu/guest_thread.cpp b/UnleashedRecomp/cpu/guest_thread.cpp index 21010ee1..9d37a9ca 100644 --- a/UnleashedRecomp/cpu/guest_thread.cpp +++ b/UnleashedRecomp/cpu/guest_thread.cpp @@ -22,12 +22,12 @@ GuestThreadContext::GuestThreadContext(uint32_t cpuNumber) thread = (uint8_t*)g_userHeap.Alloc(TOTAL_SIZE); memset(thread, 0, TOTAL_SIZE); - *(uint32_t*)thread = std::byteswap(g_memory.MapVirtual(thread + PCR_SIZE)); // tls pointer - *(uint32_t*)(thread + 0x100) = std::byteswap(g_memory.MapVirtual(thread + PCR_SIZE + TLS_SIZE)); // teb pointer + *(uint32_t*)thread = ByteSwap(g_memory.MapVirtual(thread + PCR_SIZE)); // tls pointer + *(uint32_t*)(thread + 0x100) = ByteSwap(g_memory.MapVirtual(thread + PCR_SIZE + TLS_SIZE)); // teb pointer *(thread + 0x10C) = cpuNumber; *(uint32_t*)(thread + PCR_SIZE + 0x10) = 0xFFFFFFFF; // that one TLS entry that felt quirky - *(uint32_t*)(thread + PCR_SIZE + TLS_SIZE + 0x14C) = std::byteswap(GetCurrentThreadId()); // thread id + *(uint32_t*)(thread + PCR_SIZE + TLS_SIZE + 0x14C) = ByteSwap(GetCurrentThreadId()); // thread id ppcContext.fn = (uint8_t*)g_codeCache.bucket; ppcContext.r1.u64 = g_memory.MapVirtual(thread + PCR_SIZE + TLS_SIZE + TEB_SIZE + STACK_SIZE); // stack pointer @@ -116,7 +116,7 @@ void GuestThread::SetLastError(DWORD error) } // TEB + 0x160 : Win32LastError - *(DWORD*)(thread + TEB_OFFSET + 0x160) = std::byteswap(error); + *(DWORD*)(thread + TEB_OFFSET + 0x160) = ByteSwap(error); } PPCContext* GuestThread::Invoke(uint32_t address) @@ -129,7 +129,7 @@ PPCContext* GuestThread::Invoke(uint32_t address) void SetThreadNameImpl(uint32_t a1, uint32_t threadId, uint32_t* name) { - GuestThread::SetThreadName(threadId, (const char*)g_memory.Translate(std::byteswap(*name))); + GuestThread::SetThreadName(threadId, (const char*)g_memory.Translate(ByteSwap(*name))); } int GetThreadPriorityImpl(uint32_t hThread) diff --git a/UnleashedRecomp/gpu/video.cpp b/UnleashedRecomp/gpu/video.cpp index dafaac11..07b14304 100644 --- a/UnleashedRecomp/gpu/video.cpp +++ b/UnleashedRecomp/gpu/video.cpp @@ -367,7 +367,7 @@ struct UploadAllocator for (size_t i = 0; i < size; i += sizeof(T)) { - *destination = std::byteswap(*memory); + *destination = ByteSwap(*memory); ++destination; ++memory; } @@ -1732,7 +1732,7 @@ static void UnlockBuffer(GuestBuffer* buffer, bool useCopyQueue) for (size_t i = 0; i < buffer->dataSize; i += sizeof(T)) { - *dest = std::byteswap(*src); + *dest = ByteSwap(*src); ++dest; ++src; } @@ -2251,7 +2251,7 @@ static GuestTexture* CreateTexture(uint32_t width, uint32_t height, uint32_t dep g_textureDescriptorSet->setTexture(texture->descriptorIndex, texture->texture, RenderTextureLayout::SHADER_READ, texture->textureView.get()); #ifdef _DEBUG - texture->texture->setName(std::format("Texture {:X}", g_memory.MapVirtual(texture))); + texture->texture->setName(fmt::format("Texture {:X}", g_memory.MapVirtual(texture))); #endif return texture; @@ -2263,7 +2263,7 @@ static GuestBuffer* CreateVertexBuffer(uint32_t length) buffer->buffer = g_device->createBuffer(RenderBufferDesc::VertexBuffer(length, RenderHeapType::DEFAULT, RenderBufferFlag::INDEX)); buffer->dataSize = length; #ifdef _DEBUG - buffer->buffer->setName(std::format("Vertex Buffer {:X}", g_memory.MapVirtual(buffer))); + buffer->buffer->setName(fmt::format("Vertex Buffer {:X}", g_memory.MapVirtual(buffer))); #endif return buffer; } @@ -2276,7 +2276,7 @@ static GuestBuffer* CreateIndexBuffer(uint32_t length, uint32_t, uint32_t format buffer->format = ConvertFormat(format); buffer->guestFormat = format; #ifdef _DEBUG - buffer->buffer->setName(std::format("Index Buffer {:X}", g_memory.MapVirtual(buffer))); + buffer->buffer->setName(fmt::format("Index Buffer {:X}", g_memory.MapVirtual(buffer))); #endif return buffer; } @@ -2317,7 +2317,7 @@ static GuestSurface* CreateSurface(uint32_t width, uint32_t height, uint32_t for } #ifdef _DEBUG - surface->texture->setName(std::format("{} {:X}", desc.flags & RenderTextureFlag::RENDER_TARGET ? "Render Target" : "Depth Stencil", g_memory.MapVirtual(surface))); + surface->texture->setName(fmt::format("{} {:X}", desc.flags & RenderTextureFlag::RENDER_TARGET ? "Render Target" : "Depth Stencil", g_memory.MapVirtual(surface))); #endif return surface; @@ -3055,13 +3055,13 @@ static RenderPipeline* CreateGraphicsPipelineInRenderThread(PipelineState pipeli else ++g_pipelinesCreatedInRenderThread; - pipeline->setName(std::format("{} {} {} {:X}", loading ? "ASYNC" : "", + pipeline->setName(fmt::format("{} {} {} {:X}", loading ? "ASYNC" : "", pipelineState.vertexShader->name, pipelineState.pixelShader != nullptr ? pipelineState.pixelShader->name : "", hash)); if (!loading) { std::lock_guard lock(g_debugMutex); - g_pipelineDebugText = std::format( + g_pipelineDebugText = fmt::format( "PipelineState {:X}:\n" " vertexShader: {}\n" " pixelShader: {}\n" @@ -4912,7 +4912,7 @@ static void EnqueueGraphicsPipelineCompilation(const PipelineState& pipelineStat queueItem.pipelineState = pipelineState; queueItem.databaseDataHolder = databaseDataHolderPair.counter; #ifdef ASYNC_PSO_DEBUG - queueItem.pipelineName = std::format("ASYNC {} {:X}", name, hash); + queueItem.pipelineName = fmt::format("ASYNC {} {:X}", name, hash); #endif g_pipelineStateQueue.enqueue(queueItem); } @@ -5743,18 +5743,18 @@ public: for (auto vertexDeclaration : vertexDeclarations) { - std::print(f, "static uint8_t g_vertexElements_{:016X}[] = {{", vertexDeclaration->hash); + fmt::print(f, "static uint8_t g_vertexElements_{:016X}[] = {{", vertexDeclaration->hash); auto bytes = reinterpret_cast(vertexDeclaration->vertexElements.get()); for (size_t i = 0; i < vertexDeclaration->vertexElementCount * sizeof(GuestVertexElement); i++) - std::print(f, "0x{:X},", bytes[i]); + fmt::print(f, "0x{:X},", bytes[i]); - std::println(f, "}};"); + fmt::println(f, "}};"); } for (auto& [pipelineHash, pipelineState] : pipelineStatesToCache) { - std::println(f, "{{ " + fmt::println(f, "{{ " "reinterpret_cast(0x{:X})," "reinterpret_cast(0x{:X})," "reinterpret_cast(0x{:X})," diff --git a/UnleashedRecomp/gpu/video.h b/UnleashedRecomp/gpu/video.h index dca3673b..135a7dfa 100644 --- a/UnleashedRecomp/gpu/video.h +++ b/UnleashedRecomp/gpu/video.h @@ -88,7 +88,7 @@ struct GuestResource do { originalValue = refCount.value; - incrementedValue = std::byteswap(std::byteswap(originalValue) + 1); + incrementedValue = ByteSwap(ByteSwap(originalValue) + 1); } while (InterlockedCompareExchange(reinterpret_cast(&refCount), incrementedValue, originalValue) != originalValue); } @@ -98,7 +98,7 @@ struct GuestResource do { originalValue = refCount.value; - decrementedValue = std::byteswap(std::byteswap(originalValue) - 1); + decrementedValue = ByteSwap(ByteSwap(originalValue) - 1); } while (InterlockedCompareExchange(reinterpret_cast(&refCount), decrementedValue, originalValue) != originalValue); // Normally we are supposed to release here, so only use this diff --git a/UnleashedRecomp/install/installer.cpp b/UnleashedRecomp/install/installer.cpp index 16950e0c..433adcc4 100644 --- a/UnleashedRecomp/install/installer.cpp +++ b/UnleashedRecomp/install/installer.cpp @@ -72,14 +72,14 @@ static bool copyFile(const FilePair &pair, const uint64_t *fileHashes, VirtualFi if (!sourceVfs.exists(filename)) { journal.lastResult = Journal::Result::FileMissing; - journal.lastErrorMessage = std::format("File {} does not exist in the file system.", filename); + journal.lastErrorMessage = fmt::format("File {} does not exist in the file system.", filename); return false; } if (!sourceVfs.load(filename, fileData)) { journal.lastResult = Journal::Result::FileReadFailed; - journal.lastErrorMessage = std::format("Failed to read file {} from the file system.", filename); + journal.lastErrorMessage = fmt::format("Failed to read file {} from the file system.", filename); return false; } @@ -95,7 +95,7 @@ static bool copyFile(const FilePair &pair, const uint64_t *fileHashes, VirtualFi if (!fileHashFound) { journal.lastResult = Journal::Result::FileHashFailed; - journal.lastErrorMessage = std::format("File {} from the file system did not match any of the known hashes.", filename); + journal.lastErrorMessage = fmt::format("File {} from the file system did not match any of the known hashes.", filename); return false; } } @@ -122,7 +122,7 @@ static bool copyFile(const FilePair &pair, const uint64_t *fileHashes, VirtualFi if (!outStream.is_open()) { journal.lastResult = Journal::Result::FileCreationFailed; - journal.lastErrorMessage = std::format("Failed to create file at {}.", targetPath.string()); + journal.lastErrorMessage = fmt::format("Failed to create file at {}.", targetPath.string()); return false; } @@ -132,7 +132,7 @@ static bool copyFile(const FilePair &pair, const uint64_t *fileHashes, VirtualFi if (outStream.bad()) { journal.lastResult = Journal::Result::FileWriteFailed; - journal.lastErrorMessage = std::format("Failed to create file at {}.", targetPath.string()); + journal.lastErrorMessage = fmt::format("Failed to create file at {}.", targetPath.string()); return false; } @@ -148,7 +148,7 @@ static DLC detectDLC(const std::filesystem::path &sourcePath, VirtualFileSystem if (!sourceVfs.load(DLCValidationFile, dlcXmlBytes)) { journal.lastResult = Journal::Result::FileMissing; - journal.lastErrorMessage = std::format("File {} does not exist in the file system.", DLCValidationFile); + journal.lastErrorMessage = fmt::format("File {} does not exist in the file system.", DLCValidationFile); return DLC::Unknown; } @@ -243,7 +243,7 @@ bool Installer::computeTotalSize(std::span filePairs, const uint if (!sourceVfs.exists(filename)) { journal.lastResult = Journal::Result::FileMissing; - journal.lastErrorMessage = std::format("File {} does not exist in the file system.", filename); + journal.lastErrorMessage = fmt::format("File {} does not exist in the file system.", filename); return false; } @@ -296,7 +296,7 @@ bool Installer::copyFiles(std::span filePairs, const uint64_t *f else { journal.lastResult = Journal::Result::ValidationFileMissing; - journal.lastErrorMessage = std::format("Unable to find validation file {} in file system.", validationFile); + journal.lastErrorMessage = fmt::format("Unable to find validation file {} in file system.", validationFile); return false; } diff --git a/UnleashedRecomp/install/xcontent_file_system.cpp b/UnleashedRecomp/install/xcontent_file_system.cpp index c3178262..25e8187d 100644 --- a/UnleashedRecomp/install/xcontent_file_system.cpp +++ b/UnleashedRecomp/install/xcontent_file_system.cpp @@ -635,7 +635,7 @@ bool XContentFileSystem::check(const std::filesystem::path &contentPath) uint32_t packageTypeUint = 0; contentStream.read((char *)(&packageTypeUint), sizeof(uint32_t)); - packageTypeUint = std::byteswap(packageTypeUint); + packageTypeUint = ByteSwap(packageTypeUint); XContentPackageType packageType = XContentPackageType(packageTypeUint); return packageType == XContentPackageType::CON || packageType == XContentPackageType::LIVE || packageType == XContentPackageType::PIRS; } diff --git a/UnleashedRecomp/kernel/imports.cpp b/UnleashedRecomp/kernel/imports.cpp index 32c91273..542f0971 100644 --- a/UnleashedRecomp/kernel/imports.cpp +++ b/UnleashedRecomp/kernel/imports.cpp @@ -293,7 +293,7 @@ uint32_t ExGetXConfigSetting(uint16_t Category, uint16_t Setting, void* Buffer, { // XCONFIG_SECURED_AV_REGION case 0x0002: - data[0] = std::byteswap(0x00001000); // USA/Canada + data[0] = ByteSwap(0x00001000); // USA/Canada break; default: @@ -317,22 +317,22 @@ uint32_t ExGetXConfigSetting(uint16_t Category, uint16_t Setting, void* Buffer, // XCONFIG_USER_LANGUAGE case 0x0009: - data[0] = std::byteswap((uint32_t)Config::Language.Value); + data[0] = ByteSwap((uint32_t)Config::Language.Value); break; // XCONFIG_USER_VIDEO_FLAGS case 0x000A: - data[0] = std::byteswap(0x00040000); + data[0] = ByteSwap(0x00040000); break; // XCONFIG_USER_RETAIL_FLAGS case 0x000C: - data[0] = std::byteswap(1); + data[0] = ByteSwap(1); break; // XCONFIG_USER_COUNTRY case 0x000E: - data[0] = std::byteswap(103); + data[0] = ByteSwap(103); break; default: @@ -359,7 +359,7 @@ void MmQueryStatistics() uint32_t NtCreateEvent(uint32_t* handle, void* objAttributes, uint32_t eventType, uint32_t initialState) { - *handle = std::byteswap((uint32_t)CreateEventA(nullptr, !eventType, !!initialState, nullptr)); + *handle = ByteSwap((uint32_t)CreateEventA(nullptr, !eventType, !!initialState, nullptr)); return 0; } @@ -405,7 +405,7 @@ NTSTATUS RtlUnicodeToMultiByteN(PCHAR MultiByteString, DWORD MaxBytesInMultiByte for (size_t i = 0; i < reqSize; i++) { - const auto c = std::byteswap(UnicodeString[i]); + const auto c = ByteSwap(UnicodeString[i]); MultiByteString[i] = c < 256 ? c : '?'; } @@ -518,7 +518,7 @@ uint32_t NtSuspendThread(uint32_t hThread, uint32_t* suspendCount) return E_FAIL; if (suspendCount != nullptr) - *suspendCount = std::byteswap(count); + *suspendCount = ByteSwap(count); return S_OK; } @@ -646,7 +646,7 @@ void KfAcquireSpinLock(uint32_t* spinLock) { const auto ctx = GetPPCContext(); - while (InterlockedCompareExchange((volatile long*)spinLock, std::byteswap(*(uint32_t*)(g_memory.Translate(ctx->r13.u32 + 0x110))), 0) != 0) + while (InterlockedCompareExchange((volatile long*)spinLock, ByteSwap(*(uint32_t*)(g_memory.Translate(ctx->r13.u32 + 0x110))), 0) != 0) Sleep(0); } @@ -686,7 +686,7 @@ void KeAcquireSpinLockAtRaisedIrql(uint32_t* spinLock) { const auto ctx = GetPPCContext(); - while (InterlockedCompareExchange((volatile long*)spinLock, std::byteswap(*(uint32_t*)(g_memory.Translate(ctx->r13.u32 + 0x110))), 0) != 0) + while (InterlockedCompareExchange((volatile long*)spinLock, ByteSwap(*(uint32_t*)(g_memory.Translate(ctx->r13.u32 + 0x110))), 0) != 0) Sleep(0); } @@ -1127,7 +1127,7 @@ NTSTATUS RtlMultiByteToUnicodeN(PWCH UnicodeString, ULONG MaxBytesInUnicodeStrin if (n) { for (size_t i = 0; i < n; i++) - UnicodeString[i] = std::byteswap(UnicodeString[i]); + UnicodeString[i] = ByteSwap(UnicodeString[i]); } return STATUS_SUCCESS; @@ -1156,7 +1156,7 @@ uint32_t NtResumeThread(uint32_t hThread, uint32_t* suspendCount) return E_FAIL; if (suspendCount != nullptr) - *suspendCount = std::byteswap(count); + *suspendCount = ByteSwap(count); return S_OK; } @@ -1177,7 +1177,7 @@ NTSTATUS NtReleaseSemaphore(uint32_t Handle, DWORD ReleaseCount, LONG* PreviousC ReleaseSemaphore((HANDLE)Handle, ReleaseCount, PreviousCount); if (PreviousCount) - *PreviousCount = std::byteswap(*PreviousCount); + *PreviousCount = ByteSwap(*PreviousCount); return STATUS_SUCCESS; } @@ -1216,7 +1216,7 @@ void KeQuerySystemTime(uint64_t* time) { FILETIME t; GetSystemTimeAsFileTime(&t); - *time = std::byteswap((uint64_t(t.dwHighDateTime) << 32) | t.dwLowDateTime); + *time = ByteSwap((uint64_t(t.dwHighDateTime) << 32) | t.dwLowDateTime); } void RtlTimeToTimeFields() diff --git a/UnleashedRecomp/kernel/io/file_system.cpp b/UnleashedRecomp/kernel/io/file_system.cpp index 956379c7..3ff0d41c 100644 --- a/UnleashedRecomp/kernel/io/file_system.cpp +++ b/UnleashedRecomp/kernel/io/file_system.cpp @@ -44,7 +44,7 @@ static DWORD XGetFileSizeA(uint32_t hFile, LPDWORD lpFileSizeHigh) DWORD fileSize = GetFileSize((HANDLE)hFile, lpFileSizeHigh); if (lpFileSizeHigh != nullptr) - *lpFileSizeHigh = std::byteswap(*lpFileSizeHigh); + *lpFileSizeHigh = ByteSwap(*lpFileSizeHigh); return fileSize; } @@ -54,7 +54,7 @@ BOOL XGetFileSizeExA(uint32_t hFile, PLARGE_INTEGER lpFileSize) BOOL result = GetFileSizeEx((HANDLE)hFile, lpFileSize); if (result) - lpFileSize->QuadPart = std::byteswap(lpFileSize->QuadPart); + lpFileSize->QuadPart = ByteSwap(lpFileSize->QuadPart); return result; } @@ -102,11 +102,11 @@ BOOL XReadFile DWORD XSetFilePointer(uint32_t hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod) { - LONG distanceToMoveHigh = lpDistanceToMoveHigh ? std::byteswap(*lpDistanceToMoveHigh) : 0; + LONG distanceToMoveHigh = lpDistanceToMoveHigh ? ByteSwap(*lpDistanceToMoveHigh) : 0; DWORD result = SetFilePointer((HANDLE)hFile, lDistanceToMove, lpDistanceToMoveHigh ? &distanceToMoveHigh : nullptr, dwMoveMethod); if (lpDistanceToMoveHigh != nullptr) - *lpDistanceToMoveHigh = std::byteswap(distanceToMoveHigh); + *lpDistanceToMoveHigh = ByteSwap(distanceToMoveHigh); return result; } @@ -119,7 +119,7 @@ BOOL XSetFilePointerEx(uint32_t hFile, LONG lDistanceToMove, PLARGE_INTEGER lpNe DWORD result = SetFilePointerEx((HANDLE)hFile, distanceToMove, lpNewFilePointer, dwMoveMethod); if (lpNewFilePointer != nullptr) - lpNewFilePointer->QuadPart = std::byteswap(lpNewFilePointer->QuadPart); + lpNewFilePointer->QuadPart = ByteSwap(lpNewFilePointer->QuadPart); return result; } diff --git a/UnleashedRecomp/os/logger.h b/UnleashedRecomp/os/logger.h index 5514ef4d..66793d0e 100644 --- a/UnleashedRecomp/os/logger.h +++ b/UnleashedRecomp/os/logger.h @@ -3,7 +3,7 @@ #include #define LOG_IMPL(type, func, str) os::logger::Log(str, os::logger::detail::ELogType::type, func) -#define LOGF_IMPL(type, func, str, ...) os::logger::Log(std::format(str, __VA_ARGS__), os::logger::detail::ELogType::type, func) +#define LOGF_IMPL(type, func, str, ...) os::logger::Log(fmt::format(str, __VA_ARGS__), os::logger::detail::ELogType::type, func) // Function-specific logging. diff --git a/UnleashedRecomp/os/win32/logger_win32.cpp b/UnleashedRecomp/os/win32/logger_win32.cpp index 927da16c..b95011a8 100644 --- a/UnleashedRecomp/os/win32/logger_win32.cpp +++ b/UnleashedRecomp/os/win32/logger_win32.cpp @@ -34,11 +34,11 @@ void os::logger::detail::Log(const std::string_view str, detail::ELogType type, if (func) { - std::println("[{}] {}", func, str); + fmt::println("[{}] {}", func, str); } else { - std::println("{}", str); + fmt::println("{}", str); } SetConsoleTextAttribute(g_hStandardOutput, FOREGROUND_WHITE); diff --git a/UnleashedRecomp/stdafx.h b/UnleashedRecomp/stdafx.h index a28cabac..16e8508a 100644 --- a/UnleashedRecomp/stdafx.h +++ b/UnleashedRecomp/stdafx.h @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -32,10 +31,10 @@ #include #include #include -#include #include #include #include +#include using Microsoft::WRL::ComPtr; diff --git a/UnleashedRecomp/ui/achievement_menu.cpp b/UnleashedRecomp/ui/achievement_menu.cpp index bac06e6e..a14b9af7 100644 --- a/UnleashedRecomp/ui/achievement_menu.cpp +++ b/UnleashedRecomp/ui/achievement_menu.cpp @@ -521,7 +521,7 @@ static void DrawAchievementTotal(ImVec2 min, ImVec2 max) if (records >= recordsHalfTotal || records >= ACH_RECORDS) DrawTrophySparkles(imageMin, imageMax, records, frameIndex); - auto str = std::format("{} / {}", records, ACH_RECORDS); + auto str = fmt::format("{} / {}", records, ACH_RECORDS); auto fontSize = Scale(20); auto textSize = g_fntNewRodinDB->CalcTextSizeA(fontSize, FLT_MAX, 0, str.c_str()); diff --git a/UnleashedRecomp/ui/options_menu.cpp b/UnleashedRecomp/ui/options_menu.cpp index 9cd1f05d..066b7e81 100644 --- a/UnleashedRecomp/ui/options_menu.cpp +++ b/UnleashedRecomp/ui/options_menu.cpp @@ -739,11 +739,11 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef* conf std::string valueText; if constexpr (std::is_same_v) { - valueText = std::format("{}%", int32_t(round(config->Value * 100.0f))); + valueText = fmt::format("{}%", int32_t(round(config->Value * 100.0f))); } else if constexpr (std::is_same_v) { - valueText = config->Value >= valueMax ? Localise("Options_Value_Max") : std::format("{}", config->Value); + valueText = config->Value >= valueMax ? Localise("Options_Value_Max") : fmt::format("{}", config->Value); } else { diff --git a/UnleashedRecomp/ui/window.cpp b/UnleashedRecomp/ui/window.cpp index 86546ded..767062b9 100644 --- a/UnleashedRecomp/ui/window.cpp +++ b/UnleashedRecomp/ui/window.cpp @@ -105,7 +105,7 @@ int Window_OnSDLEvent(void*, SDL_Event* event) m_isResizing = true; Window::s_width = event->window.data1; Window::s_height = event->window.data2; - Window::SetTitle(std::format("{} - [{}x{}]", Window::GetTitle(), Window::s_width, Window::s_height).c_str()); + Window::SetTitle(fmt::format("{} - [{}x{}]", Window::GetTitle(), Window::s_width, Window::s_height).c_str()); break; case SDL_WINDOWEVENT_MOVED: diff --git a/UnleashedRecomp/user/config_detail.h b/UnleashedRecomp/user/config_detail.h index e2a6d25a..5133ccad 100644 --- a/UnleashedRecomp/user/config_detail.h +++ b/UnleashedRecomp/user/config_detail.h @@ -387,24 +387,24 @@ public: if constexpr (std::is_same_v) { - result = std::format("{}", Value); + result = fmt::format("{}", Value); if (strWithQuotes) - result = std::format("\"{}\"", result); + result = fmt::format("\"{}\"", result); } else if constexpr (std::is_enum_v) { auto it = EnumTemplateReverse.find(Value); if (it != EnumTemplateReverse.end()) - result = std::format("{}", it->second); + result = fmt::format("{}", it->second); if (strWithQuotes) - result = std::format("\"{}\"", result); + result = fmt::format("\"{}\"", result); } else { - result = std::format("{}", Value); + result = fmt::format("{}", Value); } return result;