Skip to content

Commit

Permalink
Merge branch 'main' into ms-all-mods
Browse files Browse the repository at this point in the history
  • Loading branch information
GeckoEidechse authored Aug 22, 2024
2 parents c1c2075 + bebda79 commit 578018e
Show file tree
Hide file tree
Showing 117 changed files with 4,133 additions and 2,063 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@ env:
jobs:
build:
runs-on: windows-2022
strategy:
matrix:
config:
- { name: "MSVC", cc: cl }
- { name: "LLVM", cc: clang-cl }
env:
CC: ${{ matrix.config.cc }}
CXX: ${{ matrix.config.cc }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Setup msvc
Expand All @@ -31,16 +39,16 @@ jobs:
shell: bash
run: echo commit=$(git rev-parse --short HEAD) >> $GITHUB_OUTPUT
- name: Upload Build Artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: NorthstarLauncher-${{ steps.extract.outputs.commit }}
name: NorthstarLauncher-${{ matrix.config.name }}-${{ steps.extract.outputs.commit }}
path: |
game/
format-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: DoozyX/[email protected]
with:
source: 'primedev'
Expand All @@ -52,7 +60,7 @@ jobs:
format-check-cmake-files:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: puneetmatharu/[email protected]
with:
args: "--in-place"
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/merge-conflict-auto-label.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: Merge Conflict Auto Label
on:
workflow_dispatch: # Manual run
push:
branches:
- main
schedule:
- cron: "10 21 * * *"
- cron: "10 21 * * *" # Runs at 21:10; time was chosen based on contributor activity and low GitHub Actions cron load.

jobs:
triage:
Expand Down
12 changes: 11 additions & 1 deletion BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Developers who can work a command line may be interested in using [Visual Studio
- Run `cmake . -G "Ninja"` to generate build files.

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

## Linux
### Steps
1. Clone the GitHub repo
Expand All @@ -49,3 +49,13 @@ Developers who can work a command line may be interested in using [Visual Studio
* `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 .`

#### Podman

When using [`podman`](https://podman.io/) instead of Docker on an SELinux enabled distro, make sure to add the `z` flag when mounting the directory to correctly label it to avoid SELinux denying access.

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 .`
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
cmake_minimum_required(VERSION 3.15)
cmake_policy(
SET
CMP0091
NEW
)

project(
Northstar
Expand All @@ -20,6 +25,9 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_C_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_VS_PLATFORM_TOOLSET v143)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded")
# Deal with MSVC incompatiblity
add_compile_definitions(_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR)

# This determines the real binary root directory
set(NS_BINARY_DIR ${CMAKE_BINARY_DIR}/game)
Expand Down
4 changes: 2 additions & 2 deletions primedev/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include(Northstar.cmake)
include(Launcher.cmake)
include(WSockProxy.cmake)
add_subdirectory(primelauncher)
add_subdirectory(wsockproxy)
39 changes: 27 additions & 12 deletions primedev/Northstar.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
find_package(minhook REQUIRED)
find_package(libcurl REQUIRED)
find_package(minizip REQUIRED)
find_package(silver-bun REQUIRED)

add_library(
NorthstarDLL SHARED
Expand All @@ -16,6 +17,7 @@ add_library(
"client/debugoverlay.cpp"
"client/demofixes.cpp"
"client/diskvmtfixes.cpp"
"client/entity_client_tools.cpp"
"client/languagehooks.cpp"
"client/latencyflex.cpp"
"client/localchatwriter.cpp"
Expand All @@ -41,19 +43,20 @@ add_library(
"core/math/bits.h"
"core/math/color.cpp"
"core/math/color.h"
"core/math/math_pfns.h"
"core/math/vector.h"
"core/math/vplane.h"
"core/hooks.cpp"
"core/hooks.h"
"core/macros.h"
"core/memalloc.cpp"
"core/memalloc.h"
"core/memory.cpp"
"core/memory.h"
"core/sourceinterface.cpp"
"core/sourceinterface.h"
"core/structs.h"
"core/tier0.cpp"
"core/tier0.h"
"core/tier1.cpp"
"core/tier1.h"
"dedicated/dedicated.cpp"
"dedicated/dedicated.h"
"dedicated/dedicatedlogtoclient.cpp"
Expand Down Expand Up @@ -85,11 +88,16 @@ add_library(
"mods/modmanager.h"
"mods/modsavefiles.cpp"
"mods/modsavefiles.h"
"plugins/plugin_abi.h"
"plugins/pluginbackend.cpp"
"plugins/pluginbackend.h"
"plugins/interfaces/interface.h"
"plugins/interfaces/interface.cpp"
"plugins/interfaces/sys/ISys.h"
"plugins/interfaces/sys/ISys.cpp"
"plugins/interfaces/IPluginId.h"
"plugins/interfaces/IPluginCallbacks.h"
"plugins/plugins.cpp"
"plugins/plugins.h"
"plugins/pluginmanager.h"
"plugins/pluginmanager.cpp"
"scripts/client/clientchathooks.cpp"
"scripts/client/cursorposition.cpp"
"scripts/client/scriptbrowserhooks.cpp"
Expand All @@ -112,6 +120,10 @@ add_library(
"server/auth/serverauthentication.cpp"
"server/auth/serverauthentication.h"
"server/alltalk.cpp"
"server/ai_helper.cpp"
"server/ai_helper.h"
"server/ai_navmesh.cpp"
"server/ai_navmesh.h"
"server/buildainfile.cpp"
"server/r2server.cpp"
"server/r2server.h"
Expand Down Expand Up @@ -149,6 +161,8 @@ add_library(
"util/version.h"
"util/wininfo.cpp"
"util/wininfo.h"
"windows/libsys.cpp"
"windows/libsys.h"
"dllmain.cpp"
"ns_version.h"
"Northstar.def"
Expand All @@ -159,13 +173,14 @@ target_link_libraries(
PRIVATE minhook
libcurl
minizip
WS2_32.lib
Crypt32.lib
Cryptui.lib
silver-bun
ws2_32.lib
crypt32.lib
cryptui.lib
dbghelp.lib
Wldap32.lib
Normaliz.lib
Bcrypt.lib
wldap32.lib
normaliz.lib
bcrypt.lib
version.lib
)

Expand Down
35 changes: 31 additions & 4 deletions primedev/client/audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#include <iostream>
#include <sstream>
#include <random>
#include <ranges>

namespace fs = std::filesystem;

AUTOHOOK_INIT()

Expand All @@ -28,7 +31,7 @@ unsigned char EMPTY_WAVE[45] = {0x52, 0x49, 0x46, 0x46, 0x25, 0x00, 0x00, 0x00,
0x20, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x44, 0xAC, 0x00, 0x00, 0x88, 0x58,
0x01, 0x00, 0x02, 0x00, 0x10, 0x00, 0x64, 0x61, 0x74, 0x61, 0x74, 0x00, 0x00, 0x00, 0x00};

EventOverrideData::EventOverrideData(const std::string& data, const fs::path& path)
EventOverrideData::EventOverrideData(const std::string& data, const fs::path& path, const std::vector<std::string>& registeredEvents)
{
if (data.length() <= 0)
{
Expand Down Expand Up @@ -191,6 +194,14 @@ EventOverrideData::EventOverrideData(const std::string& data, const fs::path& pa
{
std::string pathString = file.path().string();

// Retrieve event id from path (standard?)
std::string eventId = file.path().parent_path().filename().string();
if (std::find(registeredEvents.begin(), registeredEvents.end(), eventId) != registeredEvents.end())
{
spdlog::warn("{} couldn't be loaded because {} event has already been overrided, skipping.", pathString, eventId);
continue;
}

// Open the file.
std::ifstream wavStream(pathString, std::ios::binary);

Expand Down Expand Up @@ -259,7 +270,7 @@ EventOverrideData::EventOverrideData(const std::string& data, const fs::path& pa
LoadedSuccessfully = true;
}

bool CustomAudioManager::TryLoadAudioOverride(const fs::path& defPath)
bool CustomAudioManager::TryLoadAudioOverride(const fs::path& defPath, std::string modName)
{
if (IsDedicatedServer())
return true; // silently fail
Expand All @@ -279,19 +290,35 @@ bool CustomAudioManager::TryLoadAudioOverride(const fs::path& defPath)

jsonStream.close();

std::shared_ptr<EventOverrideData> data = std::make_shared<EventOverrideData>(jsonStringStream.str(), defPath);
// Pass the list of overriden events to avoid multiple event registrations crash
auto kv = std::views::keys(m_loadedAudioOverrides);
std::vector<std::string> keys {kv.begin(), kv.end()};
std::shared_ptr<EventOverrideData> data = std::make_shared<EventOverrideData>(jsonStringStream.str(), defPath, keys);

if (!data->LoadedSuccessfully)
return false; // no logging, the constructor has probably already logged

for (const std::string& eventId : data->EventIds)
{
if (m_loadedAudioOverrides.contains(eventId))
{
spdlog::warn("\"{}\" mod tried to override sound event \"{}\" but it is already overriden, skipping.", modName, eventId);
continue;
}
spdlog::info("Registering sound event {}", eventId);
m_loadedAudioOverrides.insert({eventId, data});
}

for (const auto& eventIdRegexData : data->EventIdsRegex)
{
if (m_loadedAudioOverridesRegex.contains(eventIdRegexData.first))
{
spdlog::warn(
"\"{}\" mod tried to override sound event regex \"{}\" but it is already overriden, skipping.",
modName,
eventIdRegexData.first);
continue;
}
spdlog::info("Registering sound event regex {}", eventIdRegexData.first);
m_loadedAudioOverridesRegex.insert({eventIdRegexData.first, data});
}
Expand Down Expand Up @@ -445,7 +472,7 @@ bool, __fastcall, (void* sample, void* audioBuffer, unsigned int audioBufferLeng
else
{
data = dat->second.get();
dataLength = dat->first;
dataLength = (unsigned int)dat->first;
}
}

Expand Down
6 changes: 4 additions & 2 deletions primedev/client/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <regex>
#include <shared_mutex>

namespace fs = std::filesystem;

enum class AudioSelectionStrategy
{
INVALID = -1,
Expand All @@ -15,7 +17,7 @@ enum class AudioSelectionStrategy
class EventOverrideData
{
public:
EventOverrideData(const std::string&, const fs::path&);
EventOverrideData(const std::string&, const fs::path&, const std::vector<std::string>& registeredEvents);
EventOverrideData();

public:
Expand All @@ -35,7 +37,7 @@ class EventOverrideData
class CustomAudioManager
{
public:
bool TryLoadAudioOverride(const fs::path&);
bool TryLoadAudioOverride(const fs::path&, std::string modName);
void ClearAudioOverrides();

std::shared_mutex m_loadingMutex;
Expand Down
5 changes: 5 additions & 0 deletions primedev/client/cdll_client_int.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#include "toolframework/itoolentity.h"

inline IClientTools* g_pClientTools = nullptr;
Loading

0 comments on commit 578018e

Please sign in to comment.