Skip to content

Commit

Permalink
Merge pull request #30 from ccomrade/next
Browse files Browse the repository at this point in the history
Release v4
  • Loading branch information
ccomrade authored Sep 28, 2023
2 parents b826d19 + f116aa2 commit 8722785
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 63 deletions.
6 changes: 4 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*.h linguist-language=C++
*.h.in linguist-language=C++
* text=auto

*.h linguist-language=C++
*.h.in linguist-language=C++
45 changes: 45 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
################################################################################
# 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:
msvc_latest:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Prepare
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ inputs.arch }}

- name: Configure
run: cmake -S . -B Build -G "NMake Makefiles" -D CMAKE_BUILD_TYPE=${{ inputs.type }}
env:
CXXFLAGS: /W4 /WX /wd4100

- 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
23 changes: 23 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -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: Release

build_x64:
uses: ./.github/workflows/build.yml
with:
arch: x64
type: Release
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 7 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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$<$<CONFIG:Debug>:Debug>DLL")
else()
# use statically linked MSVC runtime library to avoid any unwanted DLL dependencies
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
endif()
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Code/Launcher/DedicatedServer/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

////////////////////////////////////////////////////////////////////////////////

Expand Down
21 changes: 4 additions & 17 deletions Code/Launcher/Game/LanguageHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

// ...
};
Expand Down Expand Up @@ -72,33 +67,25 @@ 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;
}

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!");
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Code/Launcher/Game/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

////////////////////////////////////////////////////////////////////////////////

Expand Down
2 changes: 1 addition & 1 deletion Code/Launcher/HeadlessServer/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

////////////////////////////////////////////////////////////////////////////////

Expand Down
33 changes: 26 additions & 7 deletions Code/Library/CPUID.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
#include <intrin.h>
#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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -105,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);
}
}

Expand All @@ -127,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;
4 changes: 2 additions & 2 deletions Code/Library/CrashLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ static void DumpLoadedModules(std::FILE* file)
LIST_ENTRY* headMod = static_cast<LIST_ENTRY*>(ByteOffset(ldr, modListOffset));

LIST_ENTRY* firstMod = NULL;
std::size_t firstModBase = -1;
std::size_t firstModBase = static_cast<std::size_t>(-1);
unsigned int modCount = 0;

for (LIST_ENTRY* mod = headMod->Flink; mod != headMod; mod = mod->Flink)
Expand Down Expand Up @@ -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<std::size_t>(-1);

for (mod = headMod->Flink; mod != headMod; mod = mod->Flink)
{
Expand Down
1 change: 1 addition & 0 deletions Code/Library/OS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ bool OS::IsVistaOrLater()
{
OSVERSIONINFOW info = {};
info.dwOSVersionInfoSize = sizeof(info);
__pragma(warning(suppress:4996))
GetVersionExW(&info);

return info.dwMajorVersion >= 6;
Expand Down
3 changes: 1 addition & 2 deletions Project.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 8722785

Please sign in to comment.