Commit Graph

1423 Commits

Author SHA1 Message Date
Sebastian Holtermann
9a536021aa renderer/HardwareBaseGPU: Fix compiler warnings 2024-10-20 00:04:13 +02:00
Sebastian Holtermann
19c7611ce5 renderer/HardwareOpenGL: Use mem_rmalloc instead of mem_malloc 2024-10-19 23:23:19 +02:00
Sebastian Holtermann
2c7a0e98a8 renderer/HardwareOpenGL: Fix compiler warnings 2024-10-19 23:15:35 +02:00
Sebastian Holtermann
7fef91e709 renderer/ShaderProgram: Fix compiler warning 2024-10-19 23:15:18 +02:00
Azamat H. Hackimov
83886a2ec7 Deduplicate code for header and CHUNK_LEVEL_INFO reading 2024-10-18 03:30:51 +03:00
Azamat H. Hackimov
b8ff1b4a2d Reworking of DisplayLevelWarpDlg()
Now level loading screen shows level name, and user can choose level from list instead of manually entering level number.
2024-10-18 03:30:51 +03:00
Azamat H. Hackimov
52b3402374 Implementing LoadLevelInfo()
This function may be used for fast information accessing such as level name or description.
2024-10-18 03:30:51 +03:00
Azamat H. Hackimov
80dc4135f6 Minor cleanups to menu.cpp 2024-10-18 02:06:52 +03:00
Azamat H. Hackimov
1f1b0d2d88 Convert some functions of Mission.cpp to std::fs::path 2024-10-18 02:06:52 +03:00
Louis Gombert
652e31f442
Merge pull request #590 from ccfly42/ui-network-settings
Add ui network settings
2024-10-15 22:48:51 +02:00
Louis Gombert
8e638e73e5
Merge pull request #630 from winterheart/filedlg-fix
Fix DoPathFileDialog() issues
2024-10-15 22:29:59 +02:00
Azamat H. Hackimov
74ac445ca6
Merge pull request #629 from pzychotic/build-editor
Re-enable building the editor
2024-10-15 12:52:56 +03:00
Azamat H. Hackimov
89be842092 Fix DoPathFileDialog() issues
Fix issue when user can select file only in LocalD3Dir. Remove listbox callback function as useless. General cleanup global and local variables.
2024-10-13 05:05:37 +03:00
Thomas Roß
eaa44aff12 [Build] Re-enable building the editor
CMAKE_SYSTEM_NAME isn't defined before the 'project' call, so moved the option below it.
2024-10-12 18:48:00 +02:00
Thomas Roß
512d441d9c
Merge pull request #626 from sebholt/mem_rmalloc_fix
Fix undefined behavior in memory allocation
2024-10-12 18:44:03 +02:00
Thomas Roß
89b5a800c8
Merge pull request #627 from sebholt/fix_pilot_cpp
Fix uninitialized string buffer access in pilot cpp
2024-10-09 19:19:58 +02:00
Sebastian Holtermann
8345055fd1 Fix another uninitialized string buffer access in pilot.cpp
The string buffer was used to obtain the file name but that was later replaced
by a std::string.  What remained was the uninitialized buffer that was fed
to logging functions where the std::string should have been used instead.

This removes the obsolete buffer and feeds the std::string to the logging
functions.
2024-10-09 10:35:49 +02:00
Sebastian Holtermann
19e6575fee Fix uninitialized string buffer access in pilot.cpp
The string buffer was used to obtain the file name but that was later replaced
by a std::string.  What remained was the uninitialized buffer that was fed
to logging functions where the std::string should have been used instead.

This removes the obsolete buffer and feeds the std::string to the logging
functions.
2024-10-09 10:32:08 +02:00
Sebastian Holtermann
15095f8763 Let mem_rmalloc call mem_malloc instead of std::malloc
`mem_rmalloc` should use `mem_malloc` instead of `std::malloc`
to match the `mem_free` deallocation call.
2024-10-07 21:05:22 +02:00
Christian Baumann
4bc1b4c7a0 Merge branch 'main' into ui-network-settings 2024-10-06 19:23:40 +02:00
Louis Gombert
48c87750f4
Merge pull request #617 from pzychotic/fix-508
Remove scaling of terrain fog ranges based on zoom
2024-10-06 13:28:14 +02:00
Louis Gombert
10c10fb1bf
Merge pull request #616 from pzychotic/fix-442
Fix crash when loading multiplayer level
2024-10-06 13:19:13 +02:00
Louis Gombert
7ca92bd1bd
Merge pull request #614 from winterheart/ddebug-update
ddebug submodule update
2024-10-05 17:21:19 +02:00
Thomas Roß
e30af1f3df [Terrain] Removed scaling of fog ranges based on zoom
This fixes visibility range decreasing massively on maximum weapon zoom of e.g. Mass Driver.
This also brings it in line with the 'non-terrain' rendering.
2024-10-05 17:20:02 +02:00
Azamat H. Hackimov
ac04ec2cda
Merge pull request #615 from pzychotic/fix-365
Fix level cutscenes sometimes not filling the screen
2024-10-05 11:47:11 +03:00
Thomas Roß
7ff05cfd27 [Player] Fixed crash when loading multiplayer level with outside player spawn position
player::start_roomnum and object::roomnum encode a terrain cell number with the highest bit set. So when accessing Terrain_seg[] we need to remove that bit to get a valid index.
2024-10-05 08:49:50 +02:00
Thomas Roß
301959d947 [Movie] Fixed level cutscenes sometimes not filling the screen 2024-10-05 08:48:50 +02:00
Azamat H. Hackimov
51da6aaae8 Remove HEAPCHECK() macro as unused 2024-10-05 05:21:41 +03:00
Azamat H. Hackimov
0e959cb4de Change error message for Int3() 2024-10-05 05:18:51 +03:00
Azamat H. Hackimov
afd5a49bd0
Merge pull request #471 from Jayman2000/additionaldir-arg
Add `-additionaldir` command-line option
2024-10-05 04:27:32 +03:00
Louis Gombert
9312711856
Merge pull request #612 from winterheart/memory-leaks-2
Fix discovered memory leaks
2024-10-04 19:44:55 +02:00
Azamat H. Hackimov
117e7d2986
Merge pull request #610 from pzychotic/followup-to-603
Reduce MAX_LOADED_MODULES to its original value
2024-09-29 21:29:21 +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
90e897918a Add start parameter to FindArg()
Before this change, the FindArg() function was well suited for finding
command-line options that only appear once. It’s very resonable for
FindArg() to only support arguments that appear one time because Descent
3 doesn’t have any command-line options that should be specified
multiple times. For example, it would be pretty pointless to do
something like this:

  Descent3 -useexedir -useexedir

or something like this:

  Descent3 -aspect 1.0 -aspect 1.6

It does, however, sometimes makes sense to repeat command-line options for
other applications. For example, you can specify -e multiple times when
running grep [1]:

  grep -e pattern1 -e pattern2 file.txt

The main motivation behind this change is to make it easier to create a
future commit. That future commit will add a command-line option named
“-additionaldir”. -additionaldir will be similar to grep’s -e flag. In
other words, it will make sense to do this:

  Descent3 -additionaldir /home/user/dir1 -additionaldir /home/user/dir2

Adding a start parameter to FindArg() now will make it easier for that
future commit parse the multiple occurrences of -additionaldir.

Unfortunately, there is one drawback to this change. In Descent3/args.h,
I gave the start parameter a default value of 1. Giving the start
parameter a default value allowed me to add the start parameter without
having to change most of the calls to the FindArg() function. There was
one situation where I had to change how FindArg was called, though.
DLLFindArg is a pointer to the FindArg() function. You cannot give
function pointers default arguments [2]. As a result,
FindArg("-someargument") works, but DLLFindArg("-someargument") does
not. Instead, you have to write DLLFindArg("-someargument", 1) which is
a little bit annoying.

[1]: <https://www.gnu.org/software/grep/manual/html_node/Matching-Control.html>
[2]: <https://stackoverflow.com/a/9760710/7593853>
2024-09-29 12:53:49 -04:00
Jason Yundt
3c602b2087 Rename base_directory to missions_directory
Before this change, there were two functions in Descent3/menu.cpp that
had parameters named base_directory. base_directory wasn’t a very good
name for those variables. We have another variable declared in
cfile/cfile.cpp named Base_directory. Confusingly, the Base_directory
variable and the base_directory parameters both referred to different
things.

For example, let’s say that a user installed Descent 3 into
/home/username/D3-open-source. In that case, the Base_directory variable
would be set to /home/username/D3-open-source and the base_directory
parameters would be set to /home/username/D3-open-source/missions.

To make the code easier to understand, this commit renames both of the
base_directory parameters to “missions_directory”.
2024-09-29 12:51:58 -04:00
Jason Yundt
9d08314986 Consolidate case-sensitive filesystem functions
Descent 3 is case-insensitive. It doesn’t matter if a file is named
“ppics.hog” or “PPPICS.HOG”. Descent 3 will load the file regardless. In
order to accomplish this, Descent 3 has to have special code for
case-sensitive filesystems. That code must take a fake case-insensitive
path and turn it into a real case-sensitive path.

Before this change, there was multiple chunks of code that helped turn
fake case-insensitive paths into real case-sensitive paths. There was
cf_FindRealFileNameCaseInsenstive(), mve_FindMovieFileRealName() and a
chunk of code in open_file_in_directory() that only exists if __LINUX__
is defined. This removes each of those pieces of code and replaces them
with a new cf_LocatePath() function.

Using the new cf_LocatePath() function has two main advantages over the
old way of doing things. First, having a single function is simpler than
having three different pieces of code. Second, the new cf_LocatePath()
function will make it easier to create a future commit. That future
commit will make Descent 3 look for files in more than just the -setdir
directory. Having a single function that’s responsible for determining
the true path of a file will make it much easier to create that future
commit.
2024-09-29 12:51:15 -04:00
Azamat H. Hackimov
ac7dd20a38 Fix memory leak from unpaired SDL_GetPrefPath() 2024-09-29 19:34:23 +03:00
Azamat H. Hackimov
2a63a8b6aa Fix memory leak from unpaired SDL_GL_LoadLibrary() 2024-09-29 19:34:23 +03:00
Jason Yundt
fc5f732347 Rename cf_FindRealFileNameCaseInsensitive()’s parameters
The main motivation behind this commit is to make it easier to create a
future commit. That futures commit will rename the
cf_FindRealFileNameCaseInsensitive() function and change its code
slightly. I was struggling to create that future commit because I found
the code in cf_FindRealFileNameCaseInsensitive() difficult to
understand. This change will make it easier to create that future commit
by making the code in cf_FindRealFileNameCaseInsensitive() easier to
understand.
2024-09-29 09:38:25 -04:00
Jason Yundt
563b9459f2 Move Base_directory into the cfile module
The main motivation behind this commit is to make it easier to create a
future commit. That future commit will will take multiple different
functions from throughout the codebase and replace them with a new
function named cf_LocatePath().

One of the functions that will get replaced is
cf_FindRealFileNameCaseInsensitive(). There are tests for
cf_FindRealFileNameCaseInsensitive() in cfile/tests/cfile_tests.cpp.
When I make that future commit, I will have to change the tests in
cfile/test/cfile_tests.cpp so that they test the cf_LocatePath()
function instead of the cf_FindRealFileNameCaseInsensitive() function.

There is an important difference between cf_LocatePath() and
cf_FindRealFileNameCaseInsensitive(). cf_LocatePath() depends on the
Base_directory variable. cf_FindRealFileNameCaseInsensitive() does not.
In order to update the tests so that they use cf_LocatePath(), I need to
make sure that the tests have access to the Base_directory variable.

Before this change, the Base_directory variable was declared in
Descent3/init.cpp. That meant that if a program wanted to access
Base_directory, then it would have to link to Descent3/init.cpp. In
other words, we would have to link to Descent3/init.cpp when compiling
the program that currently tests cf_FindRealFileNameCaseInsensitive()
but will test cf_LocatePath() in the future. I tried making that program
link to Descent3/init.cpp, but I gave up after a wile. Descent3/init.cpp
depends on a lot of other things in the codebase.

In order to make it easier to create that future commit, this commit
moves the Base_directory variable into the cfile module. When I create
that future commit, I won’t have to mess with anything linking related
because the cfile tests already link to the cfile module. Additionally,
this change will make compiling that test program more efficient.
There’s not need for the compiler to look at the entirety of
Descent3/init.cpp just because we need a single variable from it.
2024-09-29 09:15:06 -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
cef3fd1921 Don’t use Base_directory before it’s been set
Before this change, the Base_directory variable would get accessed
before we set its value. This seems to be OK. I’m not sure about the
details, but it seems like C++ guarantees that Base_directory will be
filled with zeros when it’s created.

That being said, the code that was modified by this commit used to be
misleading. The code would copy the contents of the Base_directory
variable into another variable named path. If you read the code, you
would think that path would be set to something along the lines of
"C:\\Games\\Descent3" or "/home/username/D3-open-source", but in
reality, path would be set to "". This change makes it clear that path
is guaranteed to be set to "".

The main motivation behind this commit is to make it easier to create a
future commit. That future commit will replace Base_directory with a new
variable named Base_directories. Base_directories will have a different
data type that does not get filled with zeros by default. In other
words, we need to set the new Base_directories variable before we use
it. Unfortunately, neither the current Base_directory variable nor the
future Base_directories variable will get set in time. Both of them will
be set after path variable gets set. This commit allows me to not worry
about that detail when I create the future Base_directories commit.
2024-09-28 14:37:28 -04:00
Jason Yundt
58054449e3 Remove unused arguments from mve_Init()
Before this change, mve_Init() took two arguments. Neither of the
arguments were ever used. This commit simplifies some code by removing
those unused arguments.

The main motivation behind this commit is to make it easier to make a
future commit. One of the arguments that this commit removes was named
dir. dir was a path to the movies/ directory. The future commit will
make it so that there can be more than one movies/ directory. Removing
dir means that I won’t have to mess with dir when I create that future
commit.
2024-09-28 14:36:24 -04:00
Jason Yundt
3a21380f9b Simplify CheckHogfile()
The main motivation behind this commit is to make it easier to create a
future commit. That future commit will change how CheckHogFile() finds
the path for d3.mn3 and d3_2.mn3. Simplifying CheckHogFile() now
decreases the amount of code that needs to be changed in that future
commit.
2024-09-28 14:22:35 -04:00
Jason Yundt
491af3c469 Call CheckHogfile() instead of copy pasting code
The main motivation behind this commit is to make it easier to create a
future commit. That future commit will modify code in CheckHogFile(). If
I don’t deduplicate the code now, then I’ll have to edit the same lines
of code in multiple different places.
2024-09-28 14:19:05 -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
Thomas Roß
ffc0a0448d [Osiris] Reduced MAX_LOADED_MODULES to its original value
MAX_LOADED_MODULES was increased after introduction of d3-win.hog to account for the new x64 DLLs being loadad additional to exisiting DLLs from original game data.
2024-09-27 15:28:11 +02:00
Louis Gombert
b25977c3d7
Merge pull request #603 from winterheart/cfile-update
cfile: Replace cf_LibraryFindFirst() with cf_DoForeachFileInLibrary()
2024-09-27 14:13:37 +02:00
Azamat H. Hackimov
14f9acdbd6 Don't extract scripts from outdated HOGs
Scripts from game's HOGs already outdated and should be replaced by ours from platform-dependent HOG, so don't waste time to extract them.
2024-09-26 03:52:19 +03:00
Azamat H. Hackimov
f603611490 Don't overwrite extracted script location
Fix situation when mission has own scripts with same name as our scripts. This leads to inability to load outdated mission script instead of up-to-date script from platform-dependent HOG.

Co-authored-by: Jason Yundt <jason@jasonyundt.email>
2024-09-26 03:49:39 +03:00