Commit Graph

65 Commits

Author SHA1 Message Date
Azamat H. Hackimov
1f1b0d2d88 Convert some functions of Mission.cpp to std::fs::path 2024-10-18 02:06:52 +03:00
Louis Gombert
7ca92bd1bd
Merge pull request #614 from winterheart/ddebug-update
ddebug submodule update
2024-10-05 17:21:19 +02: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
Azamat H. Hackimov
a59503f881 Move pserror.h to ddebug module 2024-09-24 23:00:53 +03: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
dc0cd880e4 Add logger module
Implementing separated logger module.
2024-09-18 22:50:08 +03:00
Jan Engelhardt
3c9234c4c0 mem_malloc type triviality checks (8/8)
(Manual modification.) Change mem_malloc callsites with
non-fundamental types to mem_rmalloc.
2024-09-16 22:12:14 +02:00
Jan Engelhardt
a23c6a42a3 mem_malloc type triviality checks (7/8)
```
git grep -l mem_malloc | xargs perl -i -lpe 's{\((char) \*\)mem_malloc\((\S+)\)}{mem_rmalloc<$1>($2)}'
```
2024-09-16 22:12:14 +02:00
Jan Engelhardt
de0af3b10d mem_malloc type triviality checks (6/8)
```
git grep -l mem_malloc | xargs perl -i -lpe 's{\((uint8_t) \*\)mem_malloc\((\S+)\)}{mem_rmalloc<$1>($2)}'
```
2024-09-16 22:12:13 +02:00
Jan Engelhardt
4d2fdb2316 mem_malloc type triviality checks (4/8)
```
git grep -l mem_malloc | xargs perl -i -lpe 's{\((\w+) \*\)mem_malloc\((\S+) \* sizeof\(\1\)\)}{mem_rmalloc<$1 *>($2)}'
```
2024-09-16 22:12:13 +02:00
Jan Engelhardt
c7da9daee2 mem_malloc type triviality checks (2/8)
Automated replacement with

```
git grep -l mem_malloc |
xargs perl -i -lpe 's{\((\w+) \*\)mem_malloc\(sizeof\(\1\) \* (\S+)\)}{mem_rmalloc<$1>($2)}'
```
2024-09-16 22:12:12 +02:00
Louis Gombert
7282af9cd8
Merge pull request #568 from winterheart/valgrind
Fix discovered memory leaks
2024-09-16 20:48:56 +02:00
Azamat H. Hackimov
4259fe4c18 Convert manage to use new logging facility 2024-09-10 03:00:25 +03:00
Azamat H. Hackimov
d185ab9514 Fix memory leaks in dedicated mode 2024-09-04 14:17:02 +03:00
Jan Engelhardt
38b835a03b Fix spello "its" 2024-09-03 13:26:51 +02:00
Jan Engelhardt
a3a31c77a2 Fix spello "seperate.." 2024-09-03 13:26:51 +02:00
Jan Engelhardt
b14470bbff Fix spello "independan.." 2024-09-03 13:26:51 +02:00
Jan Engelhardt
edbde82918 Fix spello "agression" 2024-09-03 13:26:51 +02:00
Jan Engelhardt
234e666ce0 Fix spello "charactor" 2024-09-03 13:26:51 +02: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
Thomas Roß
fdcc348b9c [Cleanup] Fixed mismatch between function declarations and implementations. 2024-08-20 20:03:02 +02:00
Thomas Roß
7b71873a69 [Cleanup] Removed function declarations that are not implemented. 2024-08-20 20:03:02 +02:00
C.W. Betts
1384aa62af Quiet warnings about uninitialized values. 2024-07-31 15:40:16 -06:00
Louis Gombert
ae5840f314
Merge pull request #502 from winterheart/modules-split
Splitting submodules of project
2024-07-30 23:17:47 +02:00
Azamat H. Hackimov
9e3563de4d Isolate model submodule
Isolate model from rest of the project, minor cleanups.
2024-07-28 16:50:42 +03:00
Louis Gombert
0d7ad92c61 Use standard temporary directory to store cache data instead of custom/cache 2024-07-26 01:22:32 +02: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
de49da0e9a DDIO: Remove unused platform-dependent functions
Remove ddio_CreateDir(), ddio_RemoveDir(), ddio_SaveWorkingDir(), ddio_RestoreWorkingDir(), ddio_DirExists(). Replace them in code with std::fs alternatives.
2024-07-01 12:50:49 +03:00
Azamat H. Hackimov
3af18dadc3 MANAGE: convert some global path variables to std::fs::path
Simplifies code related to UpdatePrimitive().
2024-07-01 12:50:49 +03:00
Azamat H. Hackimov
a00be9f71a MANAGE: refactor UpdatePrimitive() related code
Use std::fs::path on path construction, simplify code.
2024-07-01 12:50:49 +03:00
Azamat H. Hackimov
c33d99a5db MANAGE: convert UpdatePrimitive() to use std::fs::path 2024-07-01 12:50:49 +03:00
Azamat H. Hackimov
d1f0ddf888 CFILE: refactor internal paths and extensions
Refactor paths and extensions to use std::map. Rewriting related code in manage.cpp.
2024-07-01 12:50:49 +03:00
Azamat H. Hackimov
0ea758084f CFILE: refactor internal paths and extensions
Refactor paths and extensions to use std::map. Rewriting related code in manage.cpp.
2024-07-01 12:50:48 +03:00
Azamat H. Hackimov
59487976f6 Isolate misc module
Isolate misc module for better dependency handling.
2024-06-27 01:26:35 +03: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
Louis Gombert
bcca92722d Release build fixes 2024-06-07 23:50:38 +02:00
GravisZro
1c7e3053f2 Replace "PSPATHNAME_LEN" and "MAX_PATH" with "_MAX_PATH" 2024-06-01 22:19:41 -04:00
GravisZro
f7ae658fe2 Modernize struct/enum/unions type declarations 2024-05-30 03:35:17 -04:00
GravisZro
9cf9781369 Properly format/use variadic macros 2024-05-24 20:57:17 -04:00
Azamat H. Hackimov
a0929aefe2 Rename ddio_common to ddio 2024-05-24 22:18:14 +03:00
Azamat H. Hackimov
6bc3c71a83 Reordering ddio_common module
Merge ddio_lnx and ddio_win into ddio_common module.
2024-05-24 22:17:44 +03:00
GravisZro
aebe1bbbb6 Replace "ushort" with "uint16_t" and fix missing includes 2024-05-23 23:16:40 -04:00
GravisZro
26b7776f43 Replace "ubyte" with "uint8_t" 2024-05-23 23:07:26 -04:00
GravisZro
9d3e361a35 Replace "sbyte" with "int8_t" 2024-05-23 23:05:05 -04:00
GravisZro
dec9de7456 64-bit fixes
Switch all the (u)long types to (u)int32_t where appropriate.
2024-05-22 18:14:45 -04:00
Azamat H. Hackimov
3bd07d1f7e Reordering dependant on sndlib modules
Properly include and reuse produced static lib in other components.
2024-05-22 22:03:46 +03:00
Azamat H. Hackimov
3fa32ff386 Reorder headers related to linux module 2024-05-19 12:21:43 +03:00
JeodC
a4ab78192c Join license header with historical commentrs
Join the license header with historical comments using a separator so IDEs can correctly parse the initial header.

Also use .gitattributes to ensure all files are LF.
2024-05-08 14:41:19 -04:00
Edu García
3440667e93 remove unused code (mainly windows.h) 2024-05-07 23:45:33 +01:00