Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,17 @@ jobs:
run: nix build -L --no-link --keep-going '.?submodules=1#online-server.release.arm32.gcc'
- name: Build Server Release Mingw2 GCC
run: nix build -L --keep-going '.?submodules=1#online-server.release.mingw32.gcc' -o ${{ runner.temp }}/result/online-server.release.mingw32.gcc
- name: Build Client Release MingwW64 GCC
run: nix build -L --keep-going '.?submodules=1#online-client.release.mingwW64.gcc' -o ${{ runner.temp }}/result/online-client.release.mingwW64.gcc
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: online-server-windows
path: |
${{ runner.temp }}/result/online-server.release.mingw32.gcc/bin
- name: Upload client artifact
uses: actions/upload-artifact@v4
with:
name: online-client-windows
path: |
${{ runner.temp }}/result/online-client.release.mingwW64.gcc/bin
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
[submodule "externals/json"]
path = externals/json
url = https://github.com/nlohmann/json
[submodule "externals/HTTPRequest"]
path = externals/HTTPRequest
url = https://github.com/elnormous/HTTPRequest
[submodule "externals/cpp-httplib"]
path = externals/cpp-httplib
url = https://github.com/yhirose/cpp-httplib
Expand Down
6 changes: 5 additions & 1 deletion decompile/General/AltMods/OnlineCTR/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
#include <unistd.h> // for the 'usleep()' function
#endif

#define STATIC_ASSERT2(test_for_true, message) _Static_assert((test_for_true), message)
#ifdef WINDOWS_INCLUDE
#define STATIC_ASSERT2 static_assert
#else
#define STATIC_ASSERT2(test_for_true, message) _Static_assert((test_for_true), message)
#endif

#else // MSVC (Visual Studio)

Expand Down
14 changes: 14 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@
clang = callPackage ./mods/Windows/OnlineCTR/Network_PC/Server { ctrModSDK = self; stdenv = clangStdenv; trustCompiler = true; inherit withDebug; };
};
};
mkOnlineClient = withDebug: {
mingw32 = with pkgsCross.mingw32; {
gcc = callPackage ./mods/Windows/OnlineCTR/Network_PC/Client { ctrModSDK = self; inherit withDebug; };
clang = callPackage ./mods/Windows/OnlineCTR/Network_PC/Client { ctrModSDK = self; stdenv = clangStdenv; inherit withDebug; };
};
mingwW64 = with pkgsCross.mingwW64; {
gcc = callPackage ./mods/Windows/OnlineCTR/Network_PC/Client { ctrModSDK = self; inherit withDebug; };
clang = callPackage ./mods/Windows/OnlineCTR/Network_PC/Client { ctrModSDK = self; stdenv = clangStdenv; inherit withDebug; };
};
};
in
rec {
retail = {
Expand All @@ -53,6 +63,10 @@
release = mkOnline false;
debug = mkOnline true;
};
online-client = {
release = mkOnlineClient false;
debug = mkOnlineClient true;
};
};
})
{ };
Expand Down
2 changes: 1 addition & 1 deletion mods/Windows/OnlineCTR/Network_PC/Client/CL_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <Psapi.h>
#include <psapi.h>
#include <chrono>
#include <thread>

Expand Down
41 changes: 41 additions & 0 deletions mods/Windows/OnlineCTR/Network_PC/Client/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
cmake_minimum_required(VERSION 3.20)
project(OnlineCTR-Client CXX C)

set(CMAKE_C_STANDARD 99)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

# Include directories
include_directories(${PROJECT_SOURCE_DIR}/../../../../../externals/enet/include)

# Add the path to the enet library
link_directories(${PROJECT_SOURCE_DIR}/../../../../../externals/enet/lib)

# Source files
set(SOURCES CL_main.cpp DeferredMem.cpp Util.cpp)

# Create the executable
add_executable(ctr_cl ${SOURCES})

# Link with the enet library
if (WIN32)
target_link_libraries(ctr_cl enet winmm ws2_32 psapi wsock32 advapi32)
else()
target_link_libraries(ctr_cl enet)
endif()

# Compiler options
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
target_compile_options(ctr_cl PRIVATE -Wno-int-conversion -Wno-return-type)
else()
# Assume GCC
target_compile_options(ctr_cl PRIVATE)
endif()

# Debug options
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_options(ctr_cl PRIVATE -g -gdwarf-2 -O0)
else()
target_compile_options(ctr_cl PRIVATE -O2)
endif()
3 changes: 2 additions & 1 deletion mods/Windows/OnlineCTR/Network_PC/Client/DeferredMem.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifdef _WIN64 //windows
#include <WinSock2.h>
#include <winsock2.h>
#include <windows.h>
#include <ws2tcpip.h>

Expand All @@ -20,6 +20,7 @@
#include <condition_variable>
#include <map>
#include <vector>
#include <cstdio>

void recvThread();
typedef unsigned long long internalPineApiID;
Expand Down
2 changes: 1 addition & 1 deletion mods/Windows/OnlineCTR/Network_PC/Client/DeferredMem.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define DEF_MEM

#ifdef _WIN64 //windows
#include <WinSock2.h>
#include <winsock2.h>
#include <windows.h>
#include <ws2tcpip.h>
#else //assume posix
Expand Down
1 change: 1 addition & 0 deletions mods/Windows/OnlineCTR/Network_PC/Client/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <thread>
#include <process.h>

const char* exitReasons[] =
{
Expand Down
2 changes: 1 addition & 1 deletion mods/Windows/OnlineCTR/Network_PC/Client/Util.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once //why doesn't this work

const char* exitReasons[];
extern const char* exitReasons[];
extern char* progName;

void exit_execv(int code);
77 changes: 77 additions & 0 deletions mods/Windows/OnlineCTR/Network_PC/Client/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{ lib
, stdenv
, cmake
, pkg-config
, enet
, ctrModSDK ? ./../../../../..
, withDebug ? true
}:

let
isWindows = stdenv.hostPlatform.uname.system == "Windows";

mainProgram = if isWindows then "ctr_cl.exe" else "ctr_cl";

path = "mods/Windows/OnlineCTR/Network_PC/Client";

cross-enet =
if isWindows then
enet.overrideAttrs
(previousAttrs: {
nativeBuildInputs = [ cmake ];

installPhase = ''
runHook preInstall

mkdir -p $out/lib
cp libenet.a $out/lib/

runHook postInstall
'';

meta = previousAttrs.meta // { platforms = lib.platforms.all; };
})
else enet;
in
stdenv.mkDerivation (_: {
pname = "CTR-CLIENT";
version = "0.0.1";

src = ctrModSDK;
sourceRoot =
if ctrModSDK == ./../../../../.. then "CTR-ModSDK/${path}"
else "source/${path}";

nativeBuildInputs = [ cmake pkg-config ];
buildInputs = [ cross-enet ];

# Disables incompatible hardening
hardeningDisable = [ "format" ];

# Config
cmakeFlags = lib.optionals withDebug [ "-DCMAKE_BUILD_TYPE=Debug" ];

installPhase = ''
runHook preInstall

mkdir -p $out/bin
cp ${mainProgram} $out/bin/

runHook postInstall
'';

# Keep debug symbols
dontStrip = withDebug;

# Shows the proper compile date in the logs
env.SOURCE_DATE_EPOCH = (builtins.currentTime or ctrModSDK.lastModified);

meta = {
description = "CTR Online Companion";
homepage = "https://github.com/CTR-tools/CTR-ModSDK";
license = lib.licenses.publicDomain;
maintainers = with lib.maintainers; [ pedrohlc ];
mainProgram = "ctr_cl";
platforms = lib.platforms.all;
};
})