Commit Graph

111 Commits

Author SHA1 Message Date
Jan Engelhardt
61439b379d net: resolve 1 instance of -Wdelete-incomplete
Descent3/multi_dll_mgr.cpp:974:43: warning: deleting "void*" is
undefined [-Wdelete-incomplete]

(``delete`` requires that types are _complete_, so as to find the
right destructor to call; ``void`` is incomplete by definition.)
2024-11-06 18:19:08 +01:00
Jan Engelhardt
48953868df build: resolve 101 instances of -Wunused-variable 2024-11-04 22:20:18 +01:00
Azamat H. Hackimov
72e8347fe1 Move Descent3 built targets into "${CMAKE_BINARY_DIR}/build" directory
This solves problem of inability determine generated output directory of libraries targets. Now `add_custom_command()`, used on HOG generation, correctly locates all needed paths and not depends on generated variables.
2024-10-27 22:04:00 +03:00
Azamat H. Hackimov
39b205b957 Optimize building of HOG files and netgames libraries
Don't force building HOG files if dependency files are up-to-date.
Simplify building libraries by copying them into Descent3 directory.
2024-10-21 16:56:40 +03:00
Jason Yundt
f5d2a43863 Add -aditionaldir option
Before this change, Descent 3 would look for all of its game data files
in a single directory. This change allows users to spread out Descent
3’s game data over multiple directories.

Building Descent 3 produces multiple files that can be freely
redistributed (Descent3, d3-linux.hog, online/Direct TCP~IP.d3c, etc.).
Running Descent 3 requires those files and several additional files that
cannot be freely redistributed. Before this change, the files that were
redistributable had to be in the same directory as the files that were
not redistributable. This change makes it so that they can be in
separate directories.

The main motivation behind this change is to allow people to package
Descent 3 for Linux in a reasonable manner. For the most part, binary
packages for Descent 3 will contain all of the freely redistributable
components. Package managers will copy those components into system
directories that are owned by root and that users probably shouldn’t
edit manually. Users will then create a new directory and copy the game
data from their copy of Descent 3 into that new directory. Users will
then be able to run:

  Descent3 -setdir <path-to-proprietary-files> -additionaldir <path-to-open-source-files>

The -additionaldir option can also be used to support more complicated
scenarios. For example, if the user is using Debian’s
game-data-packager [1], then they would do something like this:

  Descent3 -setdir <path-to-writable-directory> -additionaldir <path-to-gdp-directory> -additionaldir <path-to-open-source-files>

The -additionaldir option can also be used to load a mod that replaces
.hog files:

  Descent3 -setdir <path-to-base-game-data> -additionaldir <path-to-mod-files>

[1]: <https://github.com/DescentDevelopers/Descent3/issues/373#issuecomment-2120330650>
2024-09-29 14:07:53 -04:00
Jason Yundt
65c9065012 Turn Base_directory into an std::filesystem::path
Before this change, Base_directory was a char array. In general, it’s
better to use an std::filesystem::path to represent paths. Here’s why:

• char arrays have a limited size. If a user creates a file or directory
that has a very long path, then it might not be possible to store that
path in a given char array. You can try to make the char array long
enough to store the longest possible path, but future operating systems
may increase that limit. With std::filesystem::paths, you don’t have
to worry about path length limits.

• char arrays cannot necessarily represent all paths. We try our best to
use UTF-8 for all char arrays [1], but unfortunately, it’s possible to
create a path that cannot be represent using UTF-8 [2]. With an
std::filesystem::paths, stuff like that is less likely to happen because
std::filesystem::path::value_type is platform-specific.

• char arrays don’t have any built-in mechanisms for manipulating paths.
Before this commit, the code would work around this problem in two
different ways:

  1. It would use Descent 3–specific functions that implement path
  operations on char arrays/pointers (for example, ddio_MakePath()).
  Once all paths use std::filesystem::path, we’ll be able to simplify
  the code by removing those functions.

  2. It would temporarily convert Base_directory into an
  std::filesystem::path. This commit simplifies the code by removing
  those temporary conversions because they are no longer necessary.

[1]: 7cd79025 (Merge pull request #494 from Jayman2000/encoding-improvements, 2024-07-20)
[2]: <https://github.com/rust-lang/rust/issues/12056>
2024-09-28 14:42:46 -04:00
Jason Yundt
72852bce3d Remove pointless cast
Before this change, API.vp[5] was cast to a pilot pointer and then cast
to a char pointer immediately afterwards. Nothing gets done to API.vp[5]
while it’s a pilot pointer, so we can remove the pilot pointer cast
without changing any behavior.
2024-09-28 14:15:28 -04:00
Louis Gombert
b33cc21dce
Merge pull request #587 from winterheart/module-fixes
Update module, add logger module
2024-09-18 22:18:13 +02:00
Azamat H. Hackimov
4f4ab3bd20 Isolate module submodule 2024-09-17 23:16:58 +03:00
Jan Engelhardt
6fbc86efec mem_malloc type triviality checks (1/8)
git grep -l mem_malloc | xargs perl -i -lpe 's{\((\w+) \*\)mem_malloc\(sizeof\(\1\)\)}{mem_rmalloc<$1>()}'
2024-09-16 21:57:41 +02:00
Azamat H. Hackimov
9ac702dcda
Merge pull request #569 from ccfly42/online-directip-netcon
Add Descent3 Online netcon
2024-09-15 23:07:38 +03:00
Christian Baumann
7501a5bcdc rename netcon 2024-09-15 13:19:26 +02:00
Christian Baumann
5b3c444032 fix memory corruption & change temp path 2024-09-15 12:38:41 +02:00
Louis Gombert
76ddbefb09
Merge pull request #570 from notimaginative/pxo_hole_punch
add support for PXO's NAT hole punch
2024-09-09 21:42:42 +02:00
Christian Baumann
0fa2b0f154 code cleanup 2024-09-09 18:51:14 +02:00
Jan Engelhardt
b9fbee0e25 Resolve out-of-bounds accesses in DLLMultiInit
vp[26] is `int *`, so it tries to read 4 bytes on amd64, even though
TCP_Active, which is behind vp[26] is just a bool and 1 byte.

==95927==ERROR: AddressSanitizer: global-buffer-overflow on address 0x000004734f40 at pc 0x7f4f8d93b952 bp 0x7ffc57f191b0 sp 0x7ffc57f191a8
READ of size 4 at 0x000004734f40 thread T0
    f0 DLLMultiInit $GIT/netcon/includes/mdllinit.h:314
    f1 LoadMultiDLL(char const*) $GIT/Descent3/multi_dll_mgr.cpp:690
    f2 RunServerConfigs $GIT/Descent3/dedicated_server.cpp:236
    f3 LoadServerConfigFile() $GIT/Descent3/dedicated_server.cpp:357
    f4 InitDedicatedServer $GIT/Descent3/init.cpp:1778
    f5 InitD3Systems2(bool) $GIT/Descent3/init.cpp:1952
    f6 Descent3() $GIT/Descent3/descent.cpp:504
    f7 oeD3LnxApp::run() $GIT/Descent3/sdlmain.cpp:151

0x000004734f41 is located 0 bytes after global variable 'TCP_active' defined in '$GIT/networking/networking.cpp:383:6' (0x4734f40) of size 1
SUMMARY: AddressSanitizer: global-buffer-overflow $GIT/netcon/includes/mdllinit.h:314 in DLLMultiInit
2024-09-09 12:15:05 +02:00
Taylor Richards
43b691dbc5
add support for PXO's NAT hole punch 2024-09-06 13:28:50 -04:00
Christian Baumann
daebe15442 fix wrong type 2024-09-05 23:36:20 +02:00
Christian Baumann
7ff07b137a init 2024-09-05 17:48:42 +02:00
Jan Engelhardt
5f0bdf8184 Fix spello "it's" 2024-09-03 13:26:51 +02:00
Azamat H. Hackimov
79db9aa3e2 Move platform-specific defines and macros to own file crossplat.h 2024-08-20 23:09:27 +03:00
Azamat H. Hackimov
22829e5e43 netcon: replace DLLddio_MakePath with std::fs::path 2024-08-20 23:09:27 +03:00
Azamat H. Hackimov
58fe55605d netcon: remove Mastertracker update check
This part of code unreachable - we don't have mtav.dll anymore, and MTUpdateURL is empty. Simplify code related version check.
2024-08-20 23:09:27 +03:00
Azamat H. Hackimov
c6d31f3820 MODULE: rewrite mod_LoadModule() to use std::fs::path 2024-08-20 23:09:27 +03:00
Azamat H. Hackimov
54f9d75e62 Reduce linux_fix.h usage in project 2024-08-20 23:08:10 +03:00
Azamat H. Hackimov
16a6866885 DDIO: new crossplatform SleepMS() function
Use C++ chrono and thread for crossplatform sleep function.
2024-08-20 23:08:10 +03:00
Azamat H. Hackimov
306db747cc Change signature of ddio_DoForeachFile()
There no return value usage across the project, change return type of function to void.
2024-08-15 11:50:36 +03:00
Azamat H. Hackimov
7c4a4d2566 DDIO: remove DLLddio_FindFileStart functions as unused
Cleanup code in core and netcon.
2024-08-15 11:50:36 +03:00
Azamat H. Hackimov
c76fc45fda NETCON: replace DLLddio_FindFileStart() with DLLddio_DoForeachFile()
Refactor code, related to game type and mission file discovery and UI representation.
2024-08-15 11:50:36 +03:00
Azamat H. Hackimov
b30597ae90 Change Multi*Settings() to use std::fs::path 2024-08-15 11:48:16 +03:00
Azamat H. Hackimov
73373205e5
Merge pull request #517 from Lgt2x/cmake-headers
CMake: add all headers to target sources
2024-08-12 15:58:05 +03:00
Louis Gombert
60c5dbf1fe CMake: add all headers to target sources
This can help with CMake IDE integration and file indexing.
2024-08-09 17:09:14 +02:00
C.W. Betts
7d5b51e8f8 macOS: Make sure the netcon modules end with dylib. 2024-08-05 15:54:38 -06:00
C.W. Betts
1384aa62af Quiet warnings about uninitialized values. 2024-07-31 15:40:16 -06:00
Azamat H. Hackimov
87882c9976 Isolate ui submodule
Isolate ui from rest of the project, minor cleanups.
2024-07-28 16:50:41 +03:00
Azamat H. Hackimov
91354d5b9a
Merge pull request #492 from tophyr/pr/posix-defines
Use `POSIX` instead of `__LINUX__` for general OS checks
2024-07-15 23:33:10 +03:00
Chris Sarbora
d6c43610fc
Fixup platform defines to be positive tests instead of negative ones 2024-07-12 18:31:05 -05:00
Chris Sarbora
3da53e567f
Programmatically replace all __LINUX__ with POSIX
Steps:
```sh
srcs=$(mktemp)
find . -name "*.cpp" -or -name "*.c" -or -name "*.h" -or -name "*.hpp" -or -name "*.cc" -or -name "*.hh" > $srcs
xargs sed -i 's/ifndef __LINUX__/if !defined(POSIX)/' < $srcs
xargs sed -i 's/ifdef __LINUX__/if defined(POSIX)/' < $srcs
xargs sed -i 's/defined(__LINUX__)/defined(POSIX)/' < $srcs
```
2024-07-12 18:11:54 -05:00
Azamat H. Hackimov
1ae023a13b Enumerate all DLL functions manually
Enumerate DLL functions to ease tying functions in main and DLL sides in code.
2024-07-09 02:08:25 +03:00
Thomas Roß
12ec7c50c7 [CMake] Enabled the CMake property USE_FOLDERS to provide a more structured project list in IDEs with the help of set(CMAKE_FOLDER "...") calls. 2024-07-03 19:55:04 +02:00
Azamat H. Hackimov
59487976f6 Isolate misc module
Isolate misc module for better dependency handling.
2024-06-27 01:26:35 +03:00
Louis Gombert
e6a2774a06
Merge pull request #463 from tophyr/single-line-genex
keep windows-specific generator expressions on one line
2024-06-24 19:24:34 +00:00
Chris Sarbora
94a0c52cdf
keep windows-specific generator expressions on one line 2024-06-24 02:07:48 -05:00
Azamat H. Hackimov
db8aa64d2f Make mem module isolated from project
Properly define MEM_USE_RTL definition only for mem library. Link other dependant modules with mem.
2024-06-20 00:43:51 +03:00
C.W. Betts
90c34c8006 Better fix for pcount. 2024-06-16 16:09:23 -06:00
C.W. Betts
2122d719e1 Remove some unused variables. 2024-06-13 14:38:17 -06:00
C.W. Betts
33b2030364 Fix compile failure. 2024-06-13 14:38:17 -06:00
C.W. Betts
f79e6cfe50 More const char* conversion. 2024-06-13 14:38:17 -06:00
Taylor Richards
ed0ff23cee
remove unnecessary return value test 2024-06-11 14:58:45 -04:00
Taylor Richards
03b729e318
fix PXO chat lobby connection failure on Linux/Mac 2024-06-10 21:55:35 -04:00