Skip to content

Commit

Permalink
Merge branch 'main' into autohook/logging.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
GeckoEidechse authored Sep 4, 2024
2 parents 6a4ad89 + b75daf3 commit b13090f
Show file tree
Hide file tree
Showing 45 changed files with 863 additions and 811 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Setup msvc
uses: ilammy/msvc-dev-cmd@v1
- name: Configure cmake
run: cmake -G "Ninja" -DCMAKE_BUILD_TYPE:STRING="${{ env.BUILD_PROFILE }}"
run: cmake -G "Ninja" -B build -DCMAKE_BUILD_TYPE:STRING="${{ env.BUILD_PROFILE }}"
- name: Setup resource file version
shell: bash
run: |
Expand All @@ -33,7 +33,7 @@ jobs:
FILEVERSION=$(echo ${{ env.NORTHSTAR_VERSION }} | tr '.' ',' | sed -E 's/-rc[0-9]+//' | tr -d '[:alpha:]')
sed -i "s/0,0,0,1/${FILEVERSION}/g" primedev/ns_version.h
- name: Build
run: cmake --build .
run: cmake --build build/
- name: Extract Short Commit Hash
id: extract
shell: bash
Expand All @@ -43,13 +43,13 @@ jobs:
with:
name: NorthstarLauncher-${{ matrix.config.name }}-${{ steps.extract.outputs.commit }}
path: |
game/
build/game/
format-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DoozyX/clang-format-lint-action@v0.16.2
- uses: DoozyX/clang-format-lint-action@v0.18.2
with:
source: 'primedev'
exclude: 'primedev/include primedev/thirdparty primedev/wsockproxy'
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Setup msvc
uses: ilammy/msvc-dev-cmd@v1
- name: Configure cmake
run: cmake -G "Ninja" -DCMAKE_BUILD_TYPE:STRING="Release"
run: cmake -G "Ninja" -B build -DCMAKE_BUILD_TYPE:STRING="Release"
- name: Setup resource file version
shell: bash
run: |
Expand All @@ -30,22 +30,22 @@ jobs:
FILEVERSION=$(echo ${{ env.NORTHSTAR_VERSION }} | tr '.' ',' | sed -E 's/-rc[0-9]+//' | tr -d '[:alpha:]')
sed -i "s/0,0,0,1/${FILEVERSION}/g" primedev/ns_version.h
- name: Build
run: cmake --build .
run: cmake --build build/
- name: Upload launcher build as artifact
uses: actions/upload-artifact@v3
with:
name: northstar-launcher
path: |
game/*.exe
game/*.dll
game/bin/x64_retail/*.dll
build/game/*.exe
build/game/*.dll
build/game/bin/x64_retail/*.dll
- name: Upload debug build artifact
uses: actions/upload-artifact@v3
with:
name: launcher-debug-files
path: |
game/*.pdb
game/bin/x64_retail/*.pdb
build/game/*.pdb
build/game/bin/x64_retail/*.pdb
upload-launcher-to-release:
if: startsWith(github.ref, 'refs/tags/v')
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mono_crash.*

# CMake output
out/
game/
build/game/
build/
CMakeFiles/
cmake_install.cmake
Expand Down
12 changes: 6 additions & 6 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ Developers who can work a command line may be interested in using [Visual Studio

- Follow the same steps as above for Visual Studio Build Tools, but instead of opening in Visual Studio, run the Command Prompt for VS 2022 and navigate to the NorthstarLauncher.

- Run `cmake . -G "Ninja"` to generate build files.
- Run `cmake . -G "Ninja" -B build` to generate build files.

- Run `cmake --build .` to build the project.
- Run `cmake --build build/` to build the project.

## Linux
### Steps
1. Clone the GitHub repo
2. Use `cd` to navigate to the cloned repo's directory
3. Then, run the following commands in order:
* `docker build --rm -t northstar-build-fedora .`
* `docker run --rm -it -e CC=cl -e CXX=cl --mount type=bind,source="$(pwd)",destination=/build northstar-build-fedora cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_NAME=Windows -G "Ninja"`
* `docker run --rm -it -e CC=cl -e CXX=cl --mount type=bind,source="$(pwd)",destination=/build northstar-build-fedora cmake --build .`
* `docker run --rm -it -e CC=cl -e CXX=cl --mount type=bind,source="$(pwd)",destination=/build northstar-build-fedora cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_NAME=Windows -G "Ninja" -B build`
* `docker run --rm -it -e CC=cl -e CXX=cl --mount type=bind,source="$(pwd)",destination=/build northstar-build-fedora cmake --build build/`

#### Podman

Expand All @@ -57,5 +57,5 @@ When using [`podman`](https://podman.io/) instead of Docker on an SELinux enable
As such the corresponding commands are

* `podman build --rm -t northstar-build-fedora .`
* `podman run --rm -it -e CC=cl -e CXX=cl --mount type=bind,source="$(pwd)",destination=/build,z northstar-build-fedora cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_NAME=Windows -G "Ninja"`
* `podman run --rm -it -e CC=cl -e CXX=cl --mount type=bind,source="$(pwd)",destination=/build,z northstar-build-fedora cmake --build .`
* `podman run --rm -it -e CC=cl -e CXX=cl --mount type=bind,source="$(pwd)",destination=/build,z northstar-build-fedora cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_NAME=Windows -G "Ninja" -B build`
* `podman run --rm -it -e CC=cl -e CXX=cl --mount type=bind,source="$(pwd)",destination=/build,z northstar-build-fedora cmake --build build/`
24 changes: 12 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
FROM registry.fedoraproject.org/fedora-toolbox:38
RUN dnf update -y && \
dnf install -y \
git \
wine \
wine-mono \
python3 \
msitools \
python3-simplejson \
python3-six \
cmake \
ninja-build \
make \
samba \
libunwind && \
git \
wine \
wine-mono \
python3 \
msitools \
python3-simplejson \
python3-six \
cmake \
ninja-build \
make \
samba \
libunwind && \
dnf clean all && \
mkdir /opt/msvc/ /build

Expand Down
18 changes: 17 additions & 1 deletion primedev/Northstar.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ add_library(
"squirrel/squirrelautobind.cpp"
"squirrel/squirrelautobind.h"
"squirrel/squirrelclasstypes.h"
"squirrel/squirreldatatypes.h"
"util/printcommands.cpp"
"util/printcommands.h"
"util/printmaps.cpp"
Expand All @@ -162,6 +161,23 @@ add_library(
"util/version.h"
"util/wininfo.cpp"
"util/wininfo.h"
"vscript/languages/squirrel_re/include/squirrel.h"
"vscript/languages/squirrel_re/squirrel/sqarray.h"
"vscript/languages/squirrel_re/squirrel/sqclosure.h"
"vscript/languages/squirrel_re/squirrel/sqcompiler.h"
"vscript/languages/squirrel_re/squirrel/sqfunctionproto.h"
"vscript/languages/squirrel_re/squirrel/sqlexer.h"
"vscript/languages/squirrel_re/squirrel/sqobject.h"
"vscript/languages/squirrel_re/squirrel/sqopcodes.h"
"vscript/languages/squirrel_re/squirrel/sqstate.h"
"vscript/languages/squirrel_re/squirrel/sqstring.h"
"vscript/languages/squirrel_re/squirrel/sqstruct.h"
"vscript/languages/squirrel_re/squirrel/sqtable.h"
"vscript/languages/squirrel_re/squirrel/squserdata.h"
"vscript/languages/squirrel_re/squirrel/sqvector.h"
"vscript/languages/squirrel_re/squirrel/sqvm.h"
"vscript/languages/squirrel_re/vsquirrel.h"
"vscript/vscript.h"
"windows/libsys.cpp"
"windows/libsys.h"
"dllmain.cpp"
Expand Down
15 changes: 6 additions & 9 deletions primedev/client/languagehooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

namespace fs = std::filesystem;

AUTOHOOK_INIT()

typedef LANGID (*Tier0_DetectDefaultLanguageType)();

bool CheckLangAudioExists(char* lang)
Expand Down Expand Up @@ -48,10 +46,8 @@ std::string GetAnyInstalledAudioLanguage()
return "NO LANGUAGE DETECTED";
}

// clang-format off
AUTOHOOK(GetGameLanguage, tier0.dll + 0xF560,
char*, __fastcall, ())
// clang-format on
static char*(__fastcall* o_pGetGameLanguage)() = nullptr;
static char* __fastcall h_GetGameLanguage()
{
auto tier0Handle = GetModuleHandleA("tier0.dll");
auto Tier0_DetectDefaultLanguageType = GetProcAddress(tier0Handle, "Tier0_DetectDefaultLanguage");
Expand All @@ -78,7 +74,7 @@ char*, __fastcall, ())

canOriginDictateLang = true; // let it try
{
auto lang = GetGameLanguage();
auto lang = o_pGetGameLanguage();
if (!CheckLangAudioExists(lang))
{
if (strcmp(lang, "russian") !=
Expand All @@ -96,7 +92,7 @@ char*, __fastcall, ())
Tier0_DetectDefaultLanguageType(); // force the global in tier0 to be populated with language inferred from user's system rather than
// defaulting to Russian
canOriginDictateLang = false; // Origin has no say anymore, we will fallback to user's system setup language
auto lang = GetGameLanguage();
auto lang = o_pGetGameLanguage();
spdlog::info("Detected system language: {}", lang);
if (!CheckLangAudioExists(lang))
{
Expand All @@ -113,5 +109,6 @@ char*, __fastcall, ())

ON_DLL_LOAD_CLIENT("tier0.dll", LanguageHooks, (CModule module))
{
AUTOHOOK_DISPATCH()
o_pGetGameLanguage = module.Offset(0xF560).RCast<decltype(o_pGetGameLanguage)>();
HookAttach(&(PVOID&)o_pGetGameLanguage, (PVOID)h_GetGameLanguage);
}
13 changes: 5 additions & 8 deletions primedev/client/latencyflex.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
#include "core/convar/convar.h"

AUTOHOOK_INIT()

ConVar* Cvar_r_latencyflex;

void (*m_winelfx_WaitAndBeginFrame)();

// clang-format off
AUTOHOOK(OnRenderStart, client.dll + 0x1952C0,
void, __fastcall, ())
// clang-format on
void(__fastcall* o_pOnRenderStart)() = nullptr;
void __fastcall h_OnRenderStart()
{
if (Cvar_r_latencyflex->GetBool() && m_winelfx_WaitAndBeginFrame)
m_winelfx_WaitAndBeginFrame();

OnRenderStart();
o_pOnRenderStart();
}

ON_DLL_LOAD_CLIENT_RELIESON("client.dll", LatencyFlex, ConVar, (CModule module))
Expand All @@ -36,7 +32,8 @@ ON_DLL_LOAD_CLIENT_RELIESON("client.dll", LatencyFlex, ConVar, (CModule module))
return;
}

AUTOHOOK_DISPATCH()
o_pOnRenderStart = module.Offset(0x1952C0).RCast<decltype(o_pOnRenderStart)>();
HookAttach(&(PVOID&)o_pOnRenderStart, (PVOID)h_OnRenderStart);

spdlog::info("LatencyFleX initialized.");
Cvar_r_latencyflex = new ConVar("r_latencyflex", "1", FCVAR_ARCHIVE, "Whether or not to use LatencyFleX input latency reduction.");
Expand Down
5 changes: 2 additions & 3 deletions primedev/core/convar/convar.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "bits.h"
#include "cvar.h"
#include "convar.h"
#include "core/sourceinterface.h"
#include "core/tier1.h"

#include <float.h>

Expand Down Expand Up @@ -35,8 +35,7 @@ ON_DLL_LOAD("engine.dll", ConVar, (CModule module))
g_pConVar_Vtable = module.Offset(0x67FD28);
g_pIConVar_Vtable = module.Offset(0x67FDC8);

g_pCVarInterface = new SourceInterface<CCvar>("vstdlib.dll", "VEngineCvar007");
g_pCVar = *g_pCVarInterface;
g_pCVar = Sys_GetFactoryPtr("vstdlib.dll", "VEngineCvar007").RCast<CCvar*>();
}

//-----------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion primedev/core/convar/cvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ std::unordered_map<std::string, ConCommandBase*> CCvar::DumpToMap()
return allConVars;
}

SourceInterface<CCvar>* g_pCVarInterface;
CCvar* g_pCVar;
1 change: 0 additions & 1 deletion primedev/core/convar/cvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,4 @@ class CCvar
std::unordered_map<std::string, ConCommandBase*> DumpToMap();
};

extern SourceInterface<CCvar>* g_pCVarInterface;
extern CCvar* g_pCVar;
Loading

0 comments on commit b13090f

Please sign in to comment.