Skip to content

Commit e3d034d

Browse files
committed
Online client: build using MinGW and CMake
1 parent c9b6425 commit e3d034d

File tree

11 files changed

+151
-8
lines changed

11 files changed

+151
-8
lines changed

.github/workflows/main.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,17 @@ jobs:
3838
run: nix build -L --no-link --keep-going '.?submodules=1#online-server.release.arm32.gcc'
3939
- name: Build Server Release Mingw2 GCC
4040
run: nix build -L --keep-going '.?submodules=1#online-server.release.mingw32.gcc' -o ${{ runner.temp }}/result/online-server.release.mingw32.gcc
41+
- name: Build Client Release MingwW64 GCC
42+
run: nix build -L --keep-going '.?submodules=1#online-client.release.mingwW64.gcc' -o ${{ runner.temp }}/result/online-client.release.mingwW64.gcc
4143
- name: Upload artifact
4244
uses: actions/upload-artifact@v4
4345
with:
4446
name: online-server-windows
4547
path: |
4648
${{ runner.temp }}/result/online-server.release.mingw32.gcc/bin
49+
- name: Upload client artifact
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: online-client-windows
53+
path: |
54+
${{ runner.temp }}/result/online-client.release.mingwW64.gcc/bin

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
[submodule "externals/json"]
2020
path = externals/json
2121
url = https://github.com/nlohmann/json
22-
[submodule "externals/HTTPRequest"]
23-
path = externals/HTTPRequest
24-
url = https://github.com/elnormous/HTTPRequest
2522
[submodule "externals/cpp-httplib"]
2623
path = externals/cpp-httplib
2724
url = https://github.com/yhirose/cpp-httplib

decompile/General/AltMods/OnlineCTR/global.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
#include <unistd.h> // for the 'usleep()' function
1515
#endif
1616

17-
#define STATIC_ASSERT2(test_for_true, message) _Static_assert((test_for_true), message)
17+
#ifdef WINDOWS_INCLUDE
18+
#define STATIC_ASSERT2 static_assert
19+
#else
20+
#define STATIC_ASSERT2(test_for_true, message) _Static_assert((test_for_true), message)
21+
#endif
1822

1923
#else // MSVC (Visual Studio)
2024

flake.nix

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@
3939
clang = callPackage ./mods/Windows/OnlineCTR/Network_PC/Server { ctrModSDK = self; stdenv = clangStdenv; trustCompiler = true; inherit withDebug; };
4040
};
4141
};
42+
mkOnlineClient = withDebug: {
43+
mingw32 = with pkgsCross.mingw32; {
44+
gcc = callPackage ./mods/Windows/OnlineCTR/Network_PC/Client { ctrModSDK = self; inherit withDebug; };
45+
clang = callPackage ./mods/Windows/OnlineCTR/Network_PC/Client { ctrModSDK = self; stdenv = clangStdenv; inherit withDebug; };
46+
};
47+
mingwW64 = with pkgsCross.mingwW64; {
48+
gcc = callPackage ./mods/Windows/OnlineCTR/Network_PC/Client { ctrModSDK = self; inherit withDebug; };
49+
clang = callPackage ./mods/Windows/OnlineCTR/Network_PC/Client { ctrModSDK = self; stdenv = clangStdenv; inherit withDebug; };
50+
};
51+
};
4252
in
4353
rec {
4454
retail = {
@@ -53,6 +63,10 @@
5363
release = mkOnline false;
5464
debug = mkOnline true;
5565
};
66+
online-client = {
67+
release = mkOnlineClient false;
68+
debug = mkOnlineClient true;
69+
};
5670
};
5771
})
5872
{ };

mods/Windows/OnlineCTR/Network_PC/Client/CL_main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <stdio.h>
55
#include <stdlib.h>
66
#include <string.h>
7-
#include <Psapi.h>
7+
#include <psapi.h>
88
#include <chrono>
99
#include <thread>
1010

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
cmake_minimum_required(VERSION 3.20)
2+
project(OnlineCTR-Client CXX C)
3+
4+
set(CMAKE_C_STANDARD 99)
5+
6+
set(CMAKE_CXX_STANDARD 17)
7+
set(CMAKE_CXX_STANDARD_REQUIRED True)
8+
9+
# Include directories
10+
include_directories(${PROJECT_SOURCE_DIR}/../../../../../externals/enet/include)
11+
12+
# Add the path to the enet library
13+
link_directories(${PROJECT_SOURCE_DIR}/../../../../../externals/enet/lib)
14+
15+
# Source files
16+
set(SOURCES CL_main.cpp DeferredMem.cpp Util.cpp)
17+
18+
# Create the executable
19+
add_executable(ctr_cl ${SOURCES})
20+
21+
# Link with the enet library
22+
if (WIN32)
23+
target_link_libraries(ctr_cl enet winmm ws2_32 psapi wsock32 advapi32)
24+
else()
25+
target_link_libraries(ctr_cl enet)
26+
endif()
27+
28+
# Compiler options
29+
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
30+
target_compile_options(ctr_cl PRIVATE -Wno-int-conversion -Wno-return-type)
31+
else()
32+
# Assume GCC
33+
target_compile_options(ctr_cl PRIVATE)
34+
endif()
35+
36+
# Debug options
37+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
38+
target_compile_options(ctr_cl PRIVATE -g -gdwarf-2 -O0)
39+
else()
40+
target_compile_options(ctr_cl PRIVATE -O2)
41+
endif()

mods/Windows/OnlineCTR/Network_PC/Client/DeferredMem.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#ifdef _WIN64 //windows
2-
#include <WinSock2.h>
2+
#include <winsock2.h>
33
#include <windows.h>
44
#include <ws2tcpip.h>
55

@@ -20,6 +20,7 @@
2020
#include <condition_variable>
2121
#include <map>
2222
#include <vector>
23+
#include <cstdio>
2324

2425
void recvThread();
2526
typedef unsigned long long internalPineApiID;

mods/Windows/OnlineCTR/Network_PC/Client/DeferredMem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#define DEF_MEM
44

55
#ifdef _WIN64 //windows
6-
#include <WinSock2.h>
6+
#include <winsock2.h>
77
#include <windows.h>
88
#include <ws2tcpip.h>
99
#else //assume posix

mods/Windows/OnlineCTR/Network_PC/Client/Util.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <stdio.h>
55
#include <stdlib.h>
66
#include <thread>
7+
#include <process.h>
78

89
const char* exitReasons[] =
910
{
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once //why doesn't this work
22

3-
const char* exitReasons[];
3+
extern const char* exitReasons[];
44
extern char* progName;
55

66
void exit_execv(int code);

0 commit comments

Comments
 (0)