From 53f5ee3dc9a2577590ba06578e2b81b939044db2 Mon Sep 17 00:00:00 2001 From: ccomrade Date: Sun, 25 Jun 2023 13:26:36 +0200 Subject: [PATCH 01/15] Update README --- README.md | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index ba51504..f741069 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # c1-launcher -An open-source replacement of the original [Crysis](https://en.wikipedia.org/wiki/Crysis_(video_game)) executables. -It provides a better game launcher and dedicated server launcher with additional features. +An open-source replacement of [Crysis (2007)](https://en.wikipedia.org/wiki/Crysis_(video_game)) executables. +It provides a better game and dedicated server launcher with additional features. ## Features @@ -10,16 +10,19 @@ It provides a better game launcher and dedicated server launcher with additional - Completely DRM-free launcher. - No compatibility mode is required to make the game work on modern systems. - Fixes all startup issues, including the well-known crash of 32-bit Crysis on modern AMD processors. +- Fixes engine crash on systems with more than 32 logical processors. +- Fixes low refresh rate in fullscreen DX10 mode. Thanks to Guzz and Vladislav. - Smaller files, especially game launcher. - Annoying startup video ads are automatically skipped. -- Very High settings are available in DX9 mode. +- Max settings (Very High) are available in DX9 mode as well. - Game running in DX9 mode can connect to DX10 servers. Everything works just like in DX10 mode. - Server does not kick players with the same CD key anymore. - It is possible to run multiple Crysis instances at once. - Advantages of pre-ordered version are available to everyone. - Details of any game or server crash are automatically written to the log file. - The `connect [IP] [PORT]` console command works without a GameSpy account. -- Fixes the low refresh rate bug in DX10 mode. Thanks to Guzz and Vladislav. +- Language detection to workaround incomplete localization files in +[Crysis from Steam](https://store.steampowered.com/app/17300/Crysis/). ## Supported game versions @@ -77,16 +80,13 @@ It provides a better game launcher and dedicated server launcher with additional ### How to use it? -Get the latest executables from the [release section](../../releases) and just replace the original files. That's it. +Get the latest executables from [releases](../../releases) and just replace the original files. -You can also compile the source code yourself. See below for [instructions](#build-instructions). +Remember that you should always use a legal copy of Crysis! -Remember that you should always use a legal copy of Crysis. -If you still don't have one, see the [list](#where-to-get-the-game) above for where you can get it. +### Is there any way to avoid replacing the original executables? -### I don't want to replace the original executables. Is there any way? - -Yes, you can rename the executables of this launcher to whatever you want and use them next to the original files. +Yes, you can rename c1-launcher executables to whatever you want and use them next to the original files. ### How can I play Crysis multiplayer? @@ -107,23 +107,23 @@ Yes, launch the game with `-splash` command line parameter. Yes, it does. There is a scrollbar in the resolution list. -### Does this launcher support Crysis Remastered? +### Does c1-launcher support Crysis Remastered? -No, it doesn't. +No, it does not. -### Does this launcher support Crysis Warhead? +### Does c1-launcher support Crysis Warhead? -No, it doesn't. The reason is that CryGame and CryAction DLLs are integrated into the EXE in Crysis Warhead. +No, it does not. The reason is that CryGame and CryAction DLLs are integrated into the EXE in Crysis Warhead. ### Why does the Bin64 folder contain 2 executables? The original `Bin64/Crysis.exe` file is actually only a 32-bit SecuROM DRM launcher. It reads the `Bin64/Crysis.ini` config file and runs `Bin64/crysis64.exe`, which is the 64-bit game launcher. However, running the game launcher -directly results in a crash during game startup. This is because the 64-bit CrySystem loads the `Bin64/b64.dll` -library with additional SecuROM garbage. It checks whether the game was launched using the DRM launcher or not, -and if not, the game crashes in a sneaky way. +directly results in a crash during game startup. This is because 64-bit CrySystem loads the `Bin64/b64.dll` library +with additional SecuROM garbage. It checks whether the game was launched using the DRM launcher, and if not, the game +crashes. -All this nonsense is skipped by this launcher. That means you can safely delete all the mentioned files. +All this nonsense is skipped by c1-launcher. That means you can safely delete all the mentioned files. ## Build instructions @@ -132,7 +132,8 @@ All this nonsense is skipped by this launcher. That means you can safely delete - Microsoft Visual C++ compiler (MSVC) >= VS2005 - CMake >= 3.15 -The source code is compatible with the legacy VS2005 compiler that was used to build Crysis. +The source code is still fully compatible with the legacy VS2005 compiler that was used to build Crysis. +It is also used to build c1-launcher releases to minimize their size and maximize compatibility. MSVC is the only supported compiler due to required ABI compatibility with Crysis DLLs. From 7d9fd29de4f4fdf050242a2699961606811ce595 Mon Sep 17 00:00:00 2001 From: ccomrade Date: Tue, 27 Jun 2023 20:30:10 +0200 Subject: [PATCH 02/15] Fix Logger --- Code/Launcher/HeadlessServer/Logger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/Launcher/HeadlessServer/Logger.cpp b/Code/Launcher/HeadlessServer/Logger.cpp index b271dba..676e07b 100644 --- a/Code/Launcher/HeadlessServer/Logger.cpp +++ b/Code/Launcher/HeadlessServer/Logger.cpp @@ -105,7 +105,7 @@ void Logger::OpenFile(const char* logPath) BackupLogFile(logPath); - if (m_file.Open(logPath, "w")) + if (!m_file.Open(logPath, "w")) { throw StringFormat_OSError("Failed to open log file!\n=> %s", logPath); } From 6c280b2666a70c4c9cc475854ed14c32f500d154 Mon Sep 17 00:00:00 2001 From: ccomrade Date: Tue, 27 Jun 2023 21:26:32 +0200 Subject: [PATCH 03/15] Cleanup --- .gitattributes | 6 ++++-- CMakeLists.txt | 16 +++++++--------- Code/Launcher/DedicatedServer/Main.cpp | 2 +- Code/Launcher/Game/Main.cpp | 2 +- Code/Launcher/HeadlessServer/Main.cpp | 2 +- Code/Library/CPUID.h | 7 ------- Project.h.in | 3 +-- README.md | 12 ++++++------ 8 files changed, 21 insertions(+), 29 deletions(-) diff --git a/.gitattributes b/.gitattributes index 607fa3c..1427df7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,4 @@ -*.h linguist-language=C++ -*.h.in linguist-language=C++ +* text=auto + +*.h linguist-language=C++ +*.h.in linguist-language=C++ diff --git a/CMakeLists.txt b/CMakeLists.txt index 186ff05..31cf996 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,13 +11,10 @@ if(NOT MSVC) endif() if(NOT CMAKE_MSVC_RUNTIME_LIBRARY) - # detect VS2005 compiler + # detect VS2005 compiler and use dynamically linked MSVC runtime library, otherwise use statically linked one if(MSVC_VERSION EQUAL 1400) - # all original Crysis DLLs are dynamically linked to MSVC runtime library from VS2005 - # use dynamically linked MSVC runtime library to reduce size of the resulting executables set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") else() - # use statically linked MSVC runtime library to avoid any unwanted DLL dependencies set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif() endif() @@ -60,20 +57,21 @@ add_library(LauncherBase STATIC Code/Library/StringView.h ) +target_link_libraries(LauncherBase PUBLIC dbghelp) + if(BUILD_BITS EQUAL 64) target_compile_definitions(LauncherBase PUBLIC BUILD_64BIT) endif() -target_compile_definitions(LauncherBase PUBLIC _CRT_SECURE_NO_WARNINGS) -target_compile_options(LauncherBase PUBLIC /W3) - +# also include PROJECT_BINARY_DIR with configured Project.h target_include_directories(LauncherBase PUBLIC Code ${PROJECT_BINARY_DIR}) +# explicitly disable some stupid MSVC warnings +target_compile_options(LauncherBase PUBLIC /D_CRT_SECURE_NO_WARNINGS /wd4351) + # prevent modern MSVC from enabling ASLR, which breaks Crysis DLLs, and unlock memory above 2 GB target_link_options(LauncherBase PUBLIC /DYNAMICBASE:NO /LARGEADDRESSAWARE) -target_link_libraries(LauncherBase PUBLIC dbghelp) - ################################################################################ add_executable(Crysis WIN32 diff --git a/Code/Launcher/DedicatedServer/Main.cpp b/Code/Launcher/DedicatedServer/Main.cpp index 0f0959c..9e82c7f 100644 --- a/Code/Launcher/DedicatedServer/Main.cpp +++ b/Code/Launcher/DedicatedServer/Main.cpp @@ -12,7 +12,7 @@ //////////////////////////////////////////////////////////////////////////////// -const char* const PROJECT_BANNER = "C1-Launcher Dedicated Server " PROJECT_VERSION_STRING " " PROJECT_BUILD_BITS; +const char* const PROJECT_BANNER = "C1-Launcher Dedicated Server " PROJECT_VERSION_STRING; //////////////////////////////////////////////////////////////////////////////// diff --git a/Code/Launcher/Game/Main.cpp b/Code/Launcher/Game/Main.cpp index e7f4cb3..ed53c99 100644 --- a/Code/Launcher/Game/Main.cpp +++ b/Code/Launcher/Game/Main.cpp @@ -12,7 +12,7 @@ //////////////////////////////////////////////////////////////////////////////// -const char* const PROJECT_BANNER = "C1-Launcher Game " PROJECT_VERSION_STRING " " PROJECT_BUILD_BITS; +const char* const PROJECT_BANNER = "C1-Launcher Game " PROJECT_VERSION_STRING; //////////////////////////////////////////////////////////////////////////////// diff --git a/Code/Launcher/HeadlessServer/Main.cpp b/Code/Launcher/HeadlessServer/Main.cpp index 89abb94..9288afe 100644 --- a/Code/Launcher/HeadlessServer/Main.cpp +++ b/Code/Launcher/HeadlessServer/Main.cpp @@ -12,7 +12,7 @@ //////////////////////////////////////////////////////////////////////////////// -const char* const PROJECT_BANNER = "C1-Launcher Headless Server " PROJECT_VERSION_STRING " " PROJECT_BUILD_BITS; +const char* const PROJECT_BANNER = "C1-Launcher Headless Server " PROJECT_VERSION_STRING; //////////////////////////////////////////////////////////////////////////////// diff --git a/Code/Library/CPUID.h b/Code/Library/CPUID.h index 4b87838..c1f3f59 100644 --- a/Code/Library/CPUID.h +++ b/Code/Library/CPUID.h @@ -7,12 +7,6 @@ #include #endif -#ifdef _MSC_VER -#define SUPPRESS_STUPID_MSVC_WARNING_C4351 __pragma(warning(suppress:4351)) -#else -#define SUPPRESS_STUPID_MSVC_WARNING_C4351 -#endif - struct CPUID { struct Query @@ -56,7 +50,6 @@ struct CPUID char brand_string[48 + 1]; char vendor_string[12 + 1]; - SUPPRESS_STUPID_MSVC_WARNING_C4351 CPUID() : vendor(VENDOR_UNKNOWN), leaf_1_edx(), leaf_80000001_edx(), brand_string(), vendor_string() { Query query(0x0); diff --git a/Project.h.in b/Project.h.in index d40eabb..a23fbdc 100644 --- a/Project.h.in +++ b/Project.h.in @@ -8,8 +8,7 @@ #pragma once #define PROJECT_VERSION @PROJECT_VERSION_MAJOR@ -#define PROJECT_VERSION_STRING "v@PROJECT_VERSION_MAJOR@" -#define PROJECT_BUILD_BITS "@BUILD_BITS@-bit" +#define PROJECT_VERSION_STRING "v@PROJECT_VERSION_MAJOR@ @BUILD_BITS@-bit" // contains launcher name and version // defined in Main.cpp of each launcher diff --git a/README.md b/README.md index f741069..9caaef4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# c1-launcher +# C1-Launcher An open-source replacement of [Crysis (2007)](https://en.wikipedia.org/wiki/Crysis_(video_game)) executables. It provides a better game and dedicated server launcher with additional features. @@ -86,7 +86,7 @@ Remember that you should always use a legal copy of Crysis! ### Is there any way to avoid replacing the original executables? -Yes, you can rename c1-launcher executables to whatever you want and use them next to the original files. +Yes, you can rename C1-Launcher executables to whatever you want and use them next to the original files. ### How can I play Crysis multiplayer? @@ -107,11 +107,11 @@ Yes, launch the game with `-splash` command line parameter. Yes, it does. There is a scrollbar in the resolution list. -### Does c1-launcher support Crysis Remastered? +### Does C1-Launcher support Crysis Remastered? No, it does not. -### Does c1-launcher support Crysis Warhead? +### Does C1-Launcher support Crysis Warhead? No, it does not. The reason is that CryGame and CryAction DLLs are integrated into the EXE in Crysis Warhead. @@ -123,7 +123,7 @@ directly results in a crash during game startup. This is because 64-bit CrySyste with additional SecuROM garbage. It checks whether the game was launched using the DRM launcher, and if not, the game crashes. -All this nonsense is skipped by c1-launcher. That means you can safely delete all the mentioned files. +All this nonsense is skipped by C1-Launcher. That means you can safely delete all the mentioned files. ## Build instructions @@ -133,7 +133,7 @@ All this nonsense is skipped by c1-launcher. That means you can safely delete al - CMake >= 3.15 The source code is still fully compatible with the legacy VS2005 compiler that was used to build Crysis. -It is also used to build c1-launcher releases to minimize their size and maximize compatibility. +It is also used to build C1-Launcher releases to minimize their size and maximize compatibility. MSVC is the only supported compiler due to required ABI compatibility with Crysis DLLs. From 2662d455dbc0c541f7838e8ee020a73b02df5432 Mon Sep 17 00:00:00 2001 From: ccomrade Date: Tue, 27 Jun 2023 22:12:56 +0200 Subject: [PATCH 04/15] Add CI builds with latest MSVC --- .github/workflows/build.yml | 43 +++++++++++++++++++++++++++++++++++++ .github/workflows/push.yml | 23 ++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/push.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..5cdc535 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,43 @@ +################################################################################ +# Reusable build workflow +################################################################################ + +name: Build + +on: + workflow_call: + inputs: + arch: + description: Either x86 or x64 + required: true + type: string + type: + description: CMake build type + required: true + type: string + +jobs: + windows_msvc: + runs-on: windows-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Prepare + uses: microsoft/setup-msbuild@v1.1 + with: + msbuild-architecture: ${{ inputs.arch }} + + - name: Configure + run: cmake -S . -B Build -D CMAKE_BUILD_TYPE=${{ inputs.type }} + + - name: Build + run: cmake --build Build + + - name: Upload + uses: actions/upload-artifact@v3 + with: + name: c1-launcher-${{ inputs.arch }} + path: | + ${{ github.workspace }}\Build\*.exe + ${{ github.workspace }}\Build\*.pdb diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 0000000..f0e0a64 --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,23 @@ +################################################################################ +# Push workflow running on a push to any branch +################################################################################ + +name: Push + +on: + push: + branches: + - '**' + +jobs: + build_x86: + uses: ./.github/workflows/build.yml + with: + arch: x86 + type: RelWithDebInfo + + build_x64: + uses: ./.github/workflows/build.yml + with: + arch: x64 + type: RelWithDebInfo From 22eb47fc0bdad7150ac37c98d5268dcfb3f2c11e Mon Sep 17 00:00:00 2001 From: ccomrade Date: Tue, 27 Jun 2023 22:18:20 +0200 Subject: [PATCH 05/15] CI: Use NMake Makefiles generator --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5cdc535..b0b8bc8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,7 +29,7 @@ jobs: msbuild-architecture: ${{ inputs.arch }} - name: Configure - run: cmake -S . -B Build -D CMAKE_BUILD_TYPE=${{ inputs.type }} + run: cmake -S . -B Build -G "NMake Makefiles" -D CMAKE_BUILD_TYPE=${{ inputs.type }} - name: Build run: cmake --build Build From 4bbc0ec57102bacbc8459714aea65dc2e21346cc Mon Sep 17 00:00:00 2001 From: ccomrade Date: Tue, 27 Jun 2023 22:33:32 +0200 Subject: [PATCH 06/15] CI: Fix MSBuild --- .github/workflows/build.yml | 8 ++++---- .github/workflows/push.yml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b0b8bc8..4a55d47 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,15 +29,15 @@ jobs: msbuild-architecture: ${{ inputs.arch }} - name: Configure - run: cmake -S . -B Build -G "NMake Makefiles" -D CMAKE_BUILD_TYPE=${{ inputs.type }} + run: cmake -S . -B Build - name: Build - run: cmake --build Build + run: cmake --build Build --config ${{ inputs.type }} - name: Upload uses: actions/upload-artifact@v3 with: name: c1-launcher-${{ inputs.arch }} path: | - ${{ github.workspace }}\Build\*.exe - ${{ github.workspace }}\Build\*.pdb + ${{ github.workspace }}\Build\${{ inputs.type }}\*.exe + ${{ github.workspace }}\Build\${{ inputs.type }}\*.pdb diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index f0e0a64..27434ed 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -14,10 +14,10 @@ jobs: uses: ./.github/workflows/build.yml with: arch: x86 - type: RelWithDebInfo + type: Release build_x64: uses: ./.github/workflows/build.yml with: arch: x64 - type: RelWithDebInfo + type: Release From 0fe53bc5b0d6a7d8dbd1a4106d615cece152f668 Mon Sep 17 00:00:00 2001 From: ccomrade Date: Tue, 27 Jun 2023 22:57:47 +0200 Subject: [PATCH 07/15] CI: Fix 32-bit build and missing PDB files --- .github/workflows/build.yml | 2 +- .github/workflows/push.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4a55d47..d1c8ed1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,7 +29,7 @@ jobs: msbuild-architecture: ${{ inputs.arch }} - name: Configure - run: cmake -S . -B Build + run: cmake -S . -B Build -A $(if ('${{ inputs.arch }}' -eq 'x86') { 'Win32' } else { '${{ inputs.arch }}' }) - name: Build run: cmake --build Build --config ${{ inputs.type }} diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 27434ed..f0e0a64 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -14,10 +14,10 @@ jobs: uses: ./.github/workflows/build.yml with: arch: x86 - type: Release + type: RelWithDebInfo build_x64: uses: ./.github/workflows/build.yml with: arch: x64 - type: Release + type: RelWithDebInfo From 7420fb1acee73dc1d7686891b76bd42aa892e7c3 Mon Sep 17 00:00:00 2001 From: ccomrade Date: Tue, 27 Jun 2023 23:13:13 +0200 Subject: [PATCH 08/15] CI: No more MSBuild --- .github/workflows/build.yml | 12 ++++++------ .github/workflows/push.yml | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d1c8ed1..f8b3487 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,20 +24,20 @@ jobs: uses: actions/checkout@v3 - name: Prepare - uses: microsoft/setup-msbuild@v1.1 + uses: ilammy/msvc-dev-cmd@v1 with: - msbuild-architecture: ${{ inputs.arch }} + arch: ${{ inputs.arch }} - name: Configure - run: cmake -S . -B Build -A $(if ('${{ inputs.arch }}' -eq 'x86') { 'Win32' } else { '${{ inputs.arch }}' }) + run: cmake -S . -B Build -G "NMake Makefiles" -D CMAKE_BUILD_TYPE=${{ inputs.type }} - name: Build - run: cmake --build Build --config ${{ inputs.type }} + run: cmake --build Build - name: Upload uses: actions/upload-artifact@v3 with: name: c1-launcher-${{ inputs.arch }} path: | - ${{ github.workspace }}\Build\${{ inputs.type }}\*.exe - ${{ github.workspace }}\Build\${{ inputs.type }}\*.pdb + ${{ github.workspace }}\Build\*.exe + ${{ github.workspace }}\Build\*.pdb diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index f0e0a64..27434ed 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -14,10 +14,10 @@ jobs: uses: ./.github/workflows/build.yml with: arch: x86 - type: RelWithDebInfo + type: Release build_x64: uses: ./.github/workflows/build.yml with: arch: x64 - type: RelWithDebInfo + type: Release From 9dc77c5f90fd0fc42a0c7855e35a6cb6fadd62a9 Mon Sep 17 00:00:00 2001 From: ccomrade Date: Tue, 27 Jun 2023 23:25:14 +0200 Subject: [PATCH 09/15] CI: Enable compiler warnings --- .github/workflows/build.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f8b3487..65751f8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ on: type: string jobs: - windows_msvc: + msvc_latest: runs-on: windows-latest steps: - name: Checkout @@ -30,6 +30,8 @@ jobs: - name: Configure run: cmake -S . -B Build -G "NMake Makefiles" -D CMAKE_BUILD_TYPE=${{ inputs.type }} + env: + CXXFLAGS: /W4 /WX - name: Build run: cmake --build Build From 08b78d62e43c51272d3962bba98ede6d5146ff25 Mon Sep 17 00:00:00 2001 From: ccomrade Date: Tue, 27 Jun 2023 23:34:32 +0200 Subject: [PATCH 10/15] CI: Fix build --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 65751f8..357fc0c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,7 +31,7 @@ jobs: - name: Configure run: cmake -S . -B Build -G "NMake Makefiles" -D CMAKE_BUILD_TYPE=${{ inputs.type }} env: - CXXFLAGS: /W4 /WX + CXXFLAGS: /W4 /WX /wd4100 - name: Build run: cmake --build Build From 79558ae5e11495fe99d1ac2be076f959084c52d1 Mon Sep 17 00:00:00 2001 From: ccomrade Date: Tue, 27 Jun 2023 23:38:23 +0200 Subject: [PATCH 11/15] Fix compiler warnings --- Code/Library/CrashLogger.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Code/Library/CrashLogger.cpp b/Code/Library/CrashLogger.cpp index e825423..2bd2f1b 100644 --- a/Code/Library/CrashLogger.cpp +++ b/Code/Library/CrashLogger.cpp @@ -268,7 +268,7 @@ static void DumpLoadedModules(std::FILE* file) LIST_ENTRY* headMod = static_cast(ByteOffset(ldr, modListOffset)); LIST_ENTRY* firstMod = NULL; - std::size_t firstModBase = -1; + std::size_t firstModBase = static_cast(-1); unsigned int modCount = 0; for (LIST_ENTRY* mod = headMod->Flink; mod != headMod; mod = mod->Flink) @@ -298,7 +298,7 @@ static void DumpLoadedModules(std::FILE* file) std::fprintf(file, ADDR_FMT " - " ADDR_FMT " %s\n", base, base + size, name); LIST_ENTRY* nextMod = NULL; - std::size_t nextModBase = -1; + std::size_t nextModBase = static_cast(-1); for (mod = headMod->Flink; mod != headMod; mod = mod->Flink) { From 97e47d71ce96c233cc8693224b128a57efaccf2b Mon Sep 17 00:00:00 2001 From: ccomrade Date: Tue, 27 Jun 2023 23:45:27 +0200 Subject: [PATCH 12/15] Fix compiler warnings --- Code/Library/OS.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Code/Library/OS.cpp b/Code/Library/OS.cpp index 8e61041..7f5166a 100644 --- a/Code/Library/OS.cpp +++ b/Code/Library/OS.cpp @@ -287,6 +287,7 @@ bool OS::IsVistaOrLater() { OSVERSIONINFOW info = {}; info.dwOSVersionInfoSize = sizeof(info); + __pragma(warning(suppress:4996)) GetVersionExW(&info); return info.dwMajorVersion >= 6; From 43b7fb972d13ae4ea984292f269ff3e162c64131 Mon Sep 17 00:00:00 2001 From: ccomrade Date: Wed, 20 Sep 2023 23:56:17 +0200 Subject: [PATCH 13/15] Fix null gEnv in Logger::RegisterConsoleVariables --- Code/Launcher/HeadlessServer/HeadlessServerLauncher.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Code/Launcher/HeadlessServer/HeadlessServerLauncher.cpp b/Code/Launcher/HeadlessServer/HeadlessServerLauncher.cpp index ee34ff1..ae569ce 100644 --- a/Code/Launcher/HeadlessServer/HeadlessServerLauncher.cpp +++ b/Code/Launcher/HeadlessServer/HeadlessServerLauncher.cpp @@ -147,6 +147,7 @@ void HeadlessServerLauncher::OnInitProgress(const char* message) void HeadlessServerLauncher::OnInit(ISystem* pSystem) { + gEnv = pSystem->GetGlobalEnvironment(); } void HeadlessServerLauncher::OnShutdown() From cee6fb7b06d942d5012ec84a3b91775c89e73822 Mon Sep 17 00:00:00 2001 From: ccomrade Date: Wed, 27 Sep 2023 00:09:49 +0200 Subject: [PATCH 14/15] Trim CPU name spaces --- Code/Library/CPUID.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Code/Library/CPUID.h b/Code/Library/CPUID.h index c1f3f59..e7fe9b1 100644 --- a/Code/Library/CPUID.h +++ b/Code/Library/CPUID.h @@ -98,6 +98,8 @@ struct CPUID std::memcpy(this->brand_string + 16, &query, 16); query = Query(0x80000004); std::memcpy(this->brand_string + 32, &query, 16); + + this->TrimSpaces(this->brand_string); } } @@ -120,6 +122,30 @@ struct CPUID { return this->vendor == VENDOR_AMD && this->leaf_80000001_edx[31]; } + +private: + void TrimSpaces(char* s) + { + char* begin = s; + char* end = s; + + while (*s == ' ') + { + s++; + } + + while (*s) + { + if (*s != ' ') + { + end = s + 1; + } + + *begin++ = *s++; + } + + *end = '\0'; + } }; extern const CPUID g_cpuid; From f116aa274f201869f66082fec997a137af3472f3 Mon Sep 17 00:00:00 2001 From: ccomrade Date: Thu, 28 Sep 2023 00:00:51 +0200 Subject: [PATCH 15/15] Finalize language hook --- CHANGELOG.md | 2 ++ Code/Launcher/Game/LanguageHook.cpp | 21 ++++----------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9aa32c4..a89d8d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +### Added +- Workaround for missing localization files in Steam version. See `LanguageHook`. ### Fixed - Fixed engine crash on systems with more than 32 CPU cores/threads. ### Changed diff --git a/Code/Launcher/Game/LanguageHook.cpp b/Code/Launcher/Game/LanguageHook.cpp index a1fab7b..bec8806 100644 --- a/Code/Launcher/Game/LanguageHook.cpp +++ b/Code/Launcher/Game/LanguageHook.cpp @@ -13,11 +13,6 @@ struct ILocalizationManager { virtual bool SetLanguage(const char* language) = 0; - virtual const char* GetLanguage() = 0; - - virtual bool LoadExcelXmlSpreadsheet(const char* filename, bool reload) = 0; - - virtual void FreeData() = 0; // ... }; @@ -72,16 +67,10 @@ static bool LanguagePakExists(const char* language) return true; } -static bool IsEmpty(const char* string) -{ - return string[0] == '\0'; -} - static const char* ChooseLanguage(const char* defaultLanguage, ICVar* pLanguageCVar) { const char* language = OS::CmdLine::GetArgValue("-language"); - - if (!IsEmpty(language)) + if (*language) { return language; } @@ -89,16 +78,14 @@ static const char* ChooseLanguage(const char* defaultLanguage, ICVar* pLanguageC if (pLanguageCVar) { const char* value = pLanguageCVar->GetString(); - - if (!IsEmpty(value)) + if (*value) { return value; } } language = defaultLanguage; - - if (!language || IsEmpty(language)) + if (!language || !*language) { CryLogErrorAlways("[Localization] Missing or invalid Game/Localized/Default.lng file!"); CryLogErrorAlways("[Localization] Trying to guess language from the system!"); @@ -162,8 +149,8 @@ static const char* ChooseLanguage(const char* defaultLanguage, ICVar* pLanguageC void LanguageHook::OnInit(const char* defaultLanguage, ILocalizationManager* pLocalizationManager) { ICVar* pLanguageCVar = gEnv->pConsole->GetCVar("g_language"); - const char* language = ChooseLanguage(defaultLanguage, pLanguageCVar); + CryLogAlways("[Localization] Using %s language", language); if (pLanguageCVar)