Skip to content

Commit

Permalink
Merge branch 'expose-version' of https://github.com/ASpoonPlaysGames/…
Browse files Browse the repository at this point in the history
…NorthstarLauncher into expose-version
  • Loading branch information
ASpoonPlaysGames committed Oct 21, 2023
2 parents 814621a + 8a61bdd commit f48bfe3
Show file tree
Hide file tree
Showing 36 changed files with 930 additions and 390 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = tab
indent_size = 4
17 changes: 17 additions & 0 deletions .github/workflows/add-to-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: add-to-project

on:
issues:
types:
- opened

jobs:
add-to-project:
name: Add to project
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
project-url: "https://github.com/orgs/R2Northstar/projects/3"
github-token: "${{ secrets.PROJECT_BOARD_TOKEN }}"

8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on: [push, pull_request]

env:
BUILD_PROFILE: Release
NORTHSTAR_VERSION: 0.0.0.${{github.run_number}}

jobs:
build:
Expand All @@ -16,6 +17,13 @@ jobs:
uses: ilammy/msvc-dev-cmd@v1
- name: Configure cmake
run: cmake -G "Ninja" -DCMAKE_BUILD_TYPE:STRING="${{ env.BUILD_PROFILE }}"
- name: Setup resource file version
shell: bash
run: |
sed -i 's/DEV/${{ env.NORTHSTAR_VERSION }}/g' NorthstarLauncher/resources.rc
sed -i 's/DEV/${{ env.NORTHSTAR_VERSION }}/g' NorthstarDLL/resources.rc
FILEVERSION=$(echo ${{ env.NORTHSTAR_VERSION }} | tr '.' ',' | sed -E 's/-rc[0-9]+//' | tr -d '[:alpha:]')
sed -i "s/0,0,0,1/${FILEVERSION}/g" NorthstarDLL/ns_version.h
- name: Build
run: cmake --build .
- name: Extract Short Commit Hash
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
shell: bash
run: |
sed -i 's/DEV/${{ env.NORTHSTAR_VERSION }}/g' NorthstarLauncher/resources.rc
sed -i 's/DEV/${{ env.NORTHSTAR_VERSION }}/g' NorthstarDLL/resources.rc
FILEVERSION=$(echo ${{ env.NORTHSTAR_VERSION }} | tr '.' ',' | sed -E 's/-rc[0-9]+//' | tr -d '[:alpha:]')
sed -i "s/0,0,0,1/${FILEVERSION}/g" NorthstarDLL/ns_version.h
- name: Build
Expand Down
10 changes: 10 additions & 0 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ The following steps will allow you to compile your own NorthstarLauncher executa

*This guide assumes you have already installed Northstar as shown in [this page](https://r2northstar.gitbook.io/r2northstar-wiki/installing-northstar/basic-setup)*

## Windows
### Steps
1. **Install Git** from [this link](https://git-scm.com)
2. **Clone** the [R2Northstar/NorthstarLauncher](https://github.com/R2Northstar/NorthstarLauncher) repo with submodules using this command `git clone --recurse-submodules https://github.com/R2Northstar/NorthstarLauncher.git`
Expand Down Expand Up @@ -39,3 +40,12 @@ 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
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 .`
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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 && \
dnf clean all && \
mkdir /opt/msvc/ /build

RUN git config --global --add safe.directory /build
RUN git clone https://github.com/mstorsjo/msvc-wine && \
./msvc-wine/vsdownload.py --accept-license --dest /opt/msvc/ && \
./msvc-wine/install.sh /opt/msvc/ && \
rm -rf ~/.wine ./msvc-wine/ && \
git config --global --add safe.directory '/build'
ENV PATH="/opt/msvc/bin/x64:${PATH}"
WORKDIR /build/
2 changes: 2 additions & 0 deletions NorthstarDLL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ find_package(minhook REQUIRED)
find_package(libcurl REQUIRED)

add_library(NorthstarDLL SHARED
"resources.rc"
"client/audio.cpp"
"client/audio.h"
"client/chatcommand.cpp"
Expand Down Expand Up @@ -90,6 +91,7 @@ add_library(NorthstarDLL SHARED
"scripts/client/scriptbrowserhooks.cpp"
"scripts/client/scriptmainmenupromos.cpp"
"scripts/client/scriptmodmenu.cpp"
"scripts/client/scriptoriginauth.cpp"
"scripts/client/scriptserverbrowser.cpp"
"scripts/client/scriptservertoclientstringcommand.cpp"
"scripts/server/miscserverfixes.cpp"
Expand Down
9 changes: 9 additions & 0 deletions NorthstarDLL/client/audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ extern "C"
extern void* __fastcall Audio_GetParentEvent();
}

ConVar* Cvar_mileslog_enable;
ConVar* Cvar_ns_print_played_sounds;

CustomAudioManager g_CustomAudioManager;
Expand Down Expand Up @@ -494,9 +495,17 @@ AUTOHOOK(MilesLog, client.dll + 0x57DAD0,
void, __fastcall, (int level, const char* string))
// clang-format on
{
if (!Cvar_mileslog_enable->GetBool())
return;

spdlog::info("[MSS] {} - {}", level, string);
}

ON_DLL_LOAD_RELIESON("engine.dll", MilesLogFuncHooks, ConVar, (CModule module))
{
Cvar_mileslog_enable = new ConVar("mileslog_enable", "0", FCVAR_NONE, "Enables/disables whether the mileslog func should be logged");
}

ON_DLL_LOAD_CLIENT_RELIESON("client.dll", AudioHooks, ConVar, (CModule module))
{
AUTOHOOK_DISPATCH()
Expand Down
2 changes: 1 addition & 1 deletion NorthstarDLL/client/rejectconnectionfixes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void,, (bool a1, const char* fmt, ...))
R2::Cbuf_AddText(R2::Cbuf_GetCurrentPlayer(), "disconnect", R2::cmd_source_t::kCommandSrcCode);
}

return COM_ExplainDisconnection(a1, buf);
return COM_ExplainDisconnection(a1, "%s", buf);
}

ON_DLL_LOAD_CLIENT("engine.dll", RejectConnectionFixes, (CModule module))
Expand Down
3 changes: 1 addition & 2 deletions NorthstarDLL/core/convar/concommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ typedef void (*FnCommandCallback_t)(const CCommand& command);
//-----------------------------------------------------------------------------
// Returns 0 to COMMAND_COMPLETION_MAXITEMS worth of completion strings
//-----------------------------------------------------------------------------
typedef int (*__fastcall FnCommandCompletionCallback)(
const char* partial, char commands[COMMAND_COMPLETION_MAXITEMS][COMMAND_COMPLETION_ITEM_LENGTH]);
typedef int (*FnCommandCompletionCallback)(const char* partial, char commands[COMMAND_COMPLETION_MAXITEMS][COMMAND_COMPLETION_ITEM_LENGTH]);

// From r5reloaded
class ConCommandBase
Expand Down
10 changes: 5 additions & 5 deletions NorthstarDLL/core/hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class __autohook
type callingConvention CONCAT2(__autohookfunc, name) args; \
namespace \
{ \
type(*callingConvention name) args; \
type(*name) args; \
__autohook CONCAT2(__autohook, __LINE__)( \
&__FILEAUTOHOOK, __STR(name), __STR(addrString), (LPVOID*)&name, (LPVOID)CONCAT2(__autohookfunc, name)); \
} \
Expand All @@ -230,7 +230,7 @@ class __autohook
type callingConvention CONCAT2(__autohookfunc, name) args; \
namespace \
{ \
type(*callingConvention name) args; \
type(*name) args; \
__autohook \
CONCAT2(__autohook, __LINE__)(&__FILEAUTOHOOK, __STR(name), addr, (LPVOID*)&name, (LPVOID)CONCAT2(__autohookfunc, name)); \
} \
Expand All @@ -241,7 +241,7 @@ class __autohook
type callingConvention CONCAT2(__autohookfunc, name) args; \
namespace \
{ \
type(*callingConvention name) args; \
type(*name) args; \
__autohook CONCAT2(__autohook, __LINE__)( \
&__FILEAUTOHOOK, __STR(name), __STR(moduleName), __STR(procName), (LPVOID*)&name, (LPVOID)CONCAT2(__autohookfunc, name)); \
} \
Expand All @@ -267,7 +267,7 @@ class ManualHook
#define HOOK(varName, originalFunc, type, callingConvention, args) \
namespace \
{ \
type(*callingConvention originalFunc) args; \
type(*originalFunc) args; \
} \
type callingConvention CONCAT2(__manualhookfunc, varName) args; \
ManualHook varName = ManualHook(__STR(varName), (LPVOID*)&originalFunc, (LPVOID)CONCAT2(__manualhookfunc, varName)); \
Expand Down Expand Up @@ -316,7 +316,7 @@ class __autovar

// FUNCTION_AT(engine.dll + 0xDEADBEEF, void, __fastcall, SomeFunc, (void* a1))
#define FUNCTION_AT(addrString, type, callingConvention, name, args) \
type(*callingConvention name) args; \
type(*name) args; \
namespace \
{ \
__autovar CONCAT2(__autovar, __LINE__)(&__FILEAUTOHOOK, __STR(addrString), (void**)&name); \
Expand Down
2 changes: 1 addition & 1 deletion NorthstarDLL/core/tier0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// use the Tier0 namespace for tier0 funcs
namespace Tier0
{
IMemAlloc* g_pMemAllocSingleton;
IMemAlloc* g_pMemAllocSingleton = nullptr;

ErrorType Error;
CommandLineType CommandLine;
Expand Down
6 changes: 5 additions & 1 deletion NorthstarDLL/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "config/profile.h"
#include "plugins/plugin_abi.h"
#include "plugins/plugins.h"
#include "plugins/pluginbackend.h"
#include "util/version.h"
#include "squirrel/squirrel.h"
#include "shared/gamepresence.h"
Expand Down Expand Up @@ -49,7 +50,9 @@ bool InitialiseNorthstar()
InitialiseVersion();
CreateLogFiles();

InitialiseCrashHandler();
g_pCrashHandler = new CCrashHandler();
bool bAllFatal = strstr(GetCommandLineA(), "-crash_handle_all") != NULL;
g_pCrashHandler->SetAllFatal(bAllFatal);

// Write launcher version to log
StartupLog();
Expand All @@ -60,6 +63,7 @@ bool InitialiseNorthstar()

g_pGameStatePresence = new GameStatePresence();
g_pPluginManager = new PluginManager();
g_pPluginCommunicationhandler = new PluginCommunicationHandler();
g_pPluginManager->LoadPlugins();

InitialiseSquirrelManagers();
Expand Down
Loading

0 comments on commit f48bfe3

Please sign in to comment.