Skip to content

Commit

Permalink
Merge branch 'main' into compiler-warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Alystrasz authored Sep 17, 2023
2 parents b4efcdc + 0cbdd56 commit 5f11143
Show file tree
Hide file tree
Showing 9 changed files with 156 additions and 20 deletions.
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/
1 change: 1 addition & 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
2 changes: 1 addition & 1 deletion NorthstarDLL/logging/loghooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ ON_DLL_LOAD_RELIESON("engine.dll", EngineSpewFuncHooks, ConVar, (CModule module)
{
AUTOHOOK_DISPATCH_MODULE(engine.dll)

Cvar_spewlog_enable = new ConVar("spewlog_enable", "1", FCVAR_NONE, "Enables/disables whether the engine spewfunc should be logged");
Cvar_spewlog_enable = new ConVar("spewlog_enable", "0", FCVAR_NONE, "Enables/disables whether the engine spewfunc should be logged");
}

ON_DLL_LOAD_CLIENT_RELIESON("client.dll", ClientPrintHooks, ConVar, (CModule module))
Expand Down
39 changes: 21 additions & 18 deletions NorthstarDLL/mods/modmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,32 +612,35 @@ void ModManager::LoadMods()
// get mod directories
std::filesystem::directory_iterator classicModsDir = fs::directory_iterator(GetModFolderPath());
std::filesystem::directory_iterator remoteModsDir = fs::directory_iterator(GetRemoteModFolderPath());
std::filesystem::directory_iterator thunderstoreModsDir = fs::directory_iterator(GetThunderstoreModFolderPath());

for (std::filesystem::directory_iterator modIterator : {classicModsDir, remoteModsDir})
for (fs::directory_entry dir : modIterator)
if (fs::exists(dir.path() / "mod.json"))
modDirs.push_back(dir.path());
for (fs::directory_entry dir : classicModsDir)
if (fs::exists(dir.path() / "mod.json"))
modDirs.push_back(dir.path());

// Special case for Thunderstore mods dir
std::filesystem::directory_iterator thunderstoreModsDir = fs::directory_iterator(GetThunderstoreModFolderPath());
// Special case for Thunderstore and remote mods directories
// Set up regex for `AUTHOR-MOD-VERSION` pattern
std::regex pattern(R"(.*\\([a-zA-Z0-9_]+)-([a-zA-Z0-9_]+)-(\d+\.\d+\.\d+))");
for (fs::directory_entry dir : thunderstoreModsDir)

for (fs::directory_iterator dirIterator : {thunderstoreModsDir, remoteModsDir})
{
fs::path modsDir = dir.path() / "mods"; // Check for mods folder in the Thunderstore mod
// Use regex to match `AUTHOR-MOD-VERSION` pattern
if (!std::regex_match(dir.path().string(), pattern))
{
spdlog::warn("The following directory did not match 'AUTHOR-MOD-VERSION': {}", dir.path().string());
continue; // skip loading mod that doesn't match
}
if (fs::exists(modsDir) && fs::is_directory(modsDir))
for (fs::directory_entry dir : dirIterator)
{
for (fs::directory_entry subDir : fs::directory_iterator(modsDir))
fs::path modsDir = dir.path() / "mods"; // Check for mods folder in the Thunderstore mod
// Use regex to match `AUTHOR-MOD-VERSION` pattern
if (!std::regex_match(dir.path().string(), pattern))
{
if (fs::exists(subDir.path() / "mod.json"))
spdlog::warn("The following directory did not match 'AUTHOR-MOD-VERSION': {}", dir.path().string());
continue; // skip loading mod that doesn't match
}
if (fs::exists(modsDir) && fs::is_directory(modsDir))
{
for (fs::directory_entry subDir : fs::directory_iterator(modsDir))
{
modDirs.push_back(subDir.path());
if (fs::exists(subDir.path() / "mod.json"))
{
modDirs.push_back(subDir.path());
}
}
}
}
Expand Down
16 changes: 16 additions & 0 deletions NorthstarDLL/resource1.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by resources.rc
//
#define IDI_ICON1 101

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
79 changes: 79 additions & 0 deletions NorthstarDLL/resources.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource1.h"
#include "../NorthstarDLL/ns_version.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE
BEGIN
"resource1.h\0"
END

2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END

3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END

#endif // APSTUDIO_INVOKED

/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION NORTHSTAR_VERSION
PRODUCTVERSION NORTHSTAR_VERSION
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "080904b0"
BEGIN
VALUE "CompanyName", "Northstar Developers"
VALUE "FileVersion", "DEV"
VALUE "InternalName", "Northstar.dll"
VALUE "LegalCopyright", "Copyright (C) 2021"
VALUE "OriginalFilename", "Northstar.dll"
VALUE "ProductVersion", "DEV"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x809, 1200
END
END

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


2 changes: 1 addition & 1 deletion NorthstarDLL/squirrel/squirrel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ ON_DLL_LOAD_RELIESON("server.dll", ServerSquirrel, ConCommand, (CModule module))
MAKEHOOK(module.Offset(0x26E20), &DestroyVMHook<ScriptContext::SERVER>, &DestroyVM<ScriptContext::SERVER>);
MAKEHOOK(module.Offset(0x799E0), &ScriptCompileErrorHook<ScriptContext::SERVER>, &SQCompileError<ScriptContext::SERVER>);
MAKEHOOK(module.Offset(0x1D5C0), &CallScriptInitCallbackHook<ScriptContext::SERVER>, &CallScriptInitCallback<ScriptContext::SERVER>);
MAKEHOOK(module.Offset(0x17BE0), &CSquirrelVM_initHook<ScriptContext::SERVER>, &CSquirrelVM_init<ScriptContext::SERVER>);
MAKEHOOK(module.Offset(0x1B7E0), &CSquirrelVM_initHook<ScriptContext::SERVER>, &CSquirrelVM_init<ScriptContext::SERVER>);
// FCVAR_CHEAT and FCVAR_GAMEDLL_FOR_REMOTE_CLIENTS allows clients to execute this, but since it's unsafe we only allow it when cheats
// are enabled for script_client and script_ui, we don't use cheats, so clients can execute them on themselves all they want
RegisterConCommand(
Expand Down

0 comments on commit 5f11143

Please sign in to comment.