Commit Graph

77 Commits

Author SHA1 Message Date
GravisZro
6a9ddd8736 Replace _vsnprintf/vsnprintf with std::vsnprintf 2024-05-24 08:52:59 -04:00
GravisZro
5e5e0c99c3 Replace "short" with "int16_t" and fix missing headers 2024-05-23 23:49:31 -04: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
3dcd21b717 Replace "unsigned short" with "uint16_t" 2024-05-23 23:03:29 -04:00
GravisZro
a00639be24 Replace "signed char" with "int8_t" 2024-05-23 22:59:50 -04:00
GravisZro
1618040db5 Replace "unsigned char" with "uint8_t" 2024-05-23 22:58:46 -04:00
GravisZro
a3a3797067 Replace "uint" with "uint32_t" 2024-05-23 22:57:25 -04:00
GravisZro
2147cfa68b Replace "unsigned int" with "uint32_t" 2024-05-23 22:51:16 -04:00
GravisZro
fb74b66bdf Fix RAND_MAX overflow errors
In `psrand.h` it attempts to undefine RAND_MAX and then redefine it.
This may work on some compilers but G++/Clang. To resolve this error
RAND_MAX was renamed to D3_RAND_MAX but **only** in files that
included `psrand.h`. The code behavior should restored to that of the
official release.
2024-05-23 20:51:25 -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
Louis Gombert
cdec632f28
Merge pull request #318 from winterheart/install-targets
Introducing installation steps
2024-05-22 18:55:36 +00:00
Louis Gombert
f5d5ea947b
Merge pull request #367 from winterheart/lnxcontroller
Reordering linux modules, cleanup code
2024-05-22 18:37:18 +00:00
Azamat H. Hackimov
08b906fcc3 Introducing installation steps
Added installation steps for all built targets. Added FORCE_PORTABLE_INSTALL cmake option that controls portable installation (only supported for now).
2024-05-22 21:35:52 +03:00
Louis Gombert
e66c359947
Merge pull request #340 from MaddTheSane/visibility
Hide module symbols by default
2024-05-22 17:39:11 +00:00
Thomas Roß
56288c819e Merge branch 'main' into win-x64 2024-05-21 00:54:53 +02:00
Jeod
3436d04ef6
Merge pull request #349 from Lgt2x/clang-warnings2
Fix some more clang warnings
2024-05-20 09:43:18 -04:00
Azamat H. Hackimov
20d38d7367 Use C99 standard vsnprintf() function 2024-05-19 12:40:50 +03:00
Thomas Roß
4072dcb3bd
Merge branch 'DescentDevelopers:main' into win-x64 2024-05-17 20:06:34 +02:00
Thomas Roß
aecd737df0 [Misc] Converted line endings to Unix format to match .gitattributes file. 2024-05-17 18:36:41 +02:00
Thomas Roß
1bf84737e5 [Scripts] Dllexport script entry points. 2024-05-15 20:09:18 +02:00
Thomas Roß
57c8347853 [Win,x64] Activated the compilation of scripts and netgames for Windows.
We now need native x64 versions of it.
2024-05-15 20:00:39 +02:00
Louis Gombert
f1d46017f5 Fix compiler warning -Wimplicit-const-int-float-conversion using explicit casts 2024-05-14 23:33:17 +02:00
C.W. Betts
6ea2633600
Update DallasFuncs.cpp
Add missing va_end calls
2024-05-13 16:04:36 -06:00
C.W. Betts
446ead20d6 Make plug-ins and modules only export select symbols. 2024-05-13 01:22:40 -06:00
Louis Gombert
196c155895 Remove Gamegauge and -timetest command-line argument
Gamegauge is an outdated 3D performance benchmark tool. The -timetest command was used to activate it. Read more about about it here: https://www.gamespot.com/articles/3d-gamegauge-explained/1100-2463688/
2024-05-12 18:32:46 +02: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
Jeod
bfb3fc1980
Merge pull request #302 from winterheart/hog-tcp-ip 2024-05-08 14:21:13 -04:00
C.W. Betts
c6da74b069
Mark functions and variables as static (#185)
* Begin by marking functions and variables as static when needed.

* More work.

* More work.

* More pokes.

* More work.

* More work.

* Initial work on the netgames.

* Revert changes to the license header on source files.

* clutter.cpp poke.

* One final poke.

* Move some declarations to headers:

Move paged_in_count and paged_in_num to gamesequence.h
Move DoneLightInstance and StartLightInstance to polymodel.h

* Look over the AI script/plug-ins.

* Going over the changes one last time.

* Fix rebase errors.

* More migration from bare statics to static inlines.
2024-05-07 23:35:28 +02:00
Azamat H. Hackimov
280dd43636 Fix search paths on Hog generation
Replaced CMAKE_BINARY_DIR with target's directory expression generator.
2024-05-07 21:18:40 +03:00
Azamat H. Hackimov
7e46ff1c06 Simplify custom targets for HOG creation
Use new features of HogMaker.
2024-05-07 19:18:49 +03:00
C.W. Betts
3adf6906ab Build the plug-ins as CMake modules. 2024-05-04 12:05:11 -06:00
Jeod
84304cf164
Merge pull request #275 from winterheart/d3-osx-hog-generate 2024-05-04 12:03:27 -04:00
Azamat H. Hackimov
ef886a2cf2 Generate d3-osx.hog for macOS
Reorganizing hog generation for Linux and macOS.
2024-05-04 16:34:36 +03:00
Jacob Coby
b64f17fb17 Merge branch '64bit-fixes' of github.com:jcoby/Descent3 into jcoby-64bit-fixes 2024-05-03 16:46:11 -04:00
Azamat H. Hackimov
940f4ff0c8 Exclude ps_srand() call from InitMathTables()
Seems this is totally unrelated to fix library API. Moved ps_srand() to appropriate places right after InitMathTables();
2024-05-03 16:22:35 -04:00
Azamat H. Hackimov
7352761bad Unbundle fix API from osiris_vector.h
Seem this was done to ease linking mission dlls. Now these missions are reusing fix as static library.
2024-05-03 16:22:35 -04:00
Louis Gombert
2d853040fa
Merge pull request #263 from MaddTheSane/oobArray
Fix a couple of out-of-bounds warnings found by Clang.
2024-05-02 17:49:33 +00:00
C.W. Betts
e1424840e1 Replace sprintf with snprintf in the merc missions. 2024-05-01 17:26:57 -06:00
C.W. Betts
1a759638ed Fix a couple of out-of-bounds warnings found by Clang. 2024-05-01 16:40:30 -06:00
Azamat H. Hackimov
9abe6aca42 Replace some of sprintf() with snprintf()
Replaced some of sprintf() (deprecated on macOS) with more secure snprintf().
2024-05-01 06:27:50 -04:00
Jacob Coby
b374d59634 Back out more ulong typedefs 2024-04-29 16:27:33 -04:00
Oskar Strengbohm
21afcaafa0 Remove asm files. 2024-04-29 21:44:32 +02:00
Jacob Coby
a6a6869a7e 64 Bit-Safe Updates
Imported Icculus' 64-bit changes.

Changes `[un]signed long` data types to `[un]signed int`.
2024-04-29 14:10:09 -04:00
Ryan C. Gordon
6c8977caf0
Heavy patching for compiler warnings.
The vast majority of this is fixing up `char *` that should be `const char *`
but a handful of other fixes, like potential buffer overflows that GCC
noticed, etc, were applied as well.

This removes `-Wno-write-strings` from CMakeLists.txt, as it is no longer
necessary, as there is no longer a flood of compiler warning spam when
building.

This does not fix all compiler warnings; there are still a handful, and they
are legitimate, but they can be dealt with in a future commit.
2024-04-29 00:18:56 -04:00
Louis Gombert
6d91c381f8
Merge pull request #179 from winterheart/checksum-unittests
Checksum unittests and Osiris types unification
2024-04-28 21:54:34 +00:00
Chris Sarbora
1bc5648a9a
Remove MacOS (Classic) code and all references (3/3)
At this point, all remaining references to `MACINTOSH` are either part
of multi-value conditionals that `unifdef` was unable to determine the
final value for, or a `#define`, or a comment. I manually go through the
files with a Ctrl+Shift+F search (ignoring legacy/, to preserve useful
historic knowledge) and clean up each usage.

As part of that search, I discovered `lib/mac/` which I deleted wholly.

Test Plan:
On Mac, build both Debug and Release
```
cmake --build --preset mac --config Debug
cmake --build --preset mac --config Release
```
2024-04-27 07:44:40 -07:00
Chris Sarbora
e6ba1906c9
Remove MacOS (Classic) code and all references (1/3)
The MACINTOSH define refers to MacOS Classic (not OS X) which we do not
plan to support. Rather than carry the cruft forever, let's delete it.

NOTE: legacy/ is unused but we're keeping it around, so MACINTOSH uses
there are left alone.

Process used for this commit:
```
git rm -r mac
find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" \) \
  -exec unifdef -UMACINTOSH -o {} {} \;
git restore legacy
git add .
```

Test Plan:
On Mac, build both Debug and Release
```
cmake --build --preset mac --config Debug
cmake --build --preset mac --config Release
```
2024-04-27 07:38:14 -07:00
Chris Sarbora
9ec7714ebc
Delete unused sources
None of these sources are referenced, either directly or indirectly,
    in any CMakeLists.txt file.

    NOTE: All of legacy/ is unused, but we're keeping it around.

    Process for this commit: (in bash)
    **NOTE: THIS MUST BE DONE ON A CASE-SENSITIVE FILESYSTEM**. There are a
    few instances of differing-in-case-only (hogmaker vs HogMaker, etc) that
    will catch you out otherwise.
    ```
      # *** 1: Find all directly-referenced c/cpp files in CMakeLists.txt
      find . -name CMakeLists.txt -exec cat {} \+ |
      # Then, convert spaces and tabs to newlines for easy tokenizing
        tr -s ' \t' '\n' |
      # Filter to just tokens descripting c/cpp filenames (case insensitive)
        grep -iE '\.c(pp)?' |
      # Massage each filename to remove CMake-specific chars
        sed 's/[")]//g' |
      # Remove a URL that happens to match the pattern so far
        grep -v https: |
      # Remove files that start with # (and are thus comments, not refs)
        grep -Ev '^#' |
      # *** 2: In the output so far there is a curious entry ${SCRIPT}.cpp
      # Turns out, the makefiles generate some further filenames from script
      # names. So, delete the ${SCRIPT}.cpp filename...
        grep -v '${SCRIPT}.cpp' |
      # .. and add in the cpps.
        (
      # We use a bash subshell to let us "concatenate" to the pipe. This
      # writes stdin back to stdout, and then starts a *new command* to
      # generate more to stdout.
          cat -;
      # All the generated script cpp references live in scripts/
          cat scripts/CMakeLists.txt |
      # Squash the makefile onto one line for regex ease
            tr '\n' ' ' |
      # Extract the script names
            sed -E 's/.*set\(SCRIPTS([^)]+)\).*/\1/' |
      # Convert spaces and tabs to newlines for easy tokenizing
            tr -s ' \t' '\n' |
      # Remove blank lines
            grep -v '^$' |
      # Add cpp extension to each token
            while read TOKEN; do
              echo ${TOKEN}.cpp;
            done
        ) |
      # *** 3: Being referenced by CMakeFiles.txt isn't the only way a src
      # file can be used - it could also be potentially #include'ed. Let's
      # find those, with another subshell concatenation:
        (
          cat -;
      # Look in ALL source files. We could actually probably limit the
      # search here to just src files listed so far in stdin + *.h, but
      # that'd require a bunch of redirections and this bash pipeline is
      # already ridiculous enough. (Case!)
          find . -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" |
      # Pull out the #include directives from them
            xargs grep --no-filename '#include' |
      # Look for any include of a .c or .cpp file (Case!)
            grep -iE '\.c(pp)?' |
      # Squash multiple spaces and tabs into one single space
            tr -s ' \t' ' ' |
      # Split on spaces, take the second field
            cut -d ' ' -f 2 |
      # Delete off quotes and angle brackets to get the included filename
            tr -d '"<>'
        ) |
      # *** 4: Protect all files under legacy/, per @Lgt2x's request
        (
          cat -;
          find legacy -iname "*.cpp" -or -iname "*.c"
        ) |
      # *** 5: Reduce all entries to their basename
        while read FILENAME; do
          basename $FILENAME;
        done |
      # *** 6: FINALLY, sort and dedupe the output into a file.
        sort | uniq > used_srcs

      # Now that we know all the used source files, we need to find all of
      # the source files in the repo, and delete them if they do not appear
      # in the used_srcs list.
      for SRC in $(find . -iname "*.cpp" -or -iname "*.c"); do
      # find outputs the relative path, we want to operate on just filename
        basename $SRC |
      # grep to see if the basename occurs in the used_srcs list.
      # -q means be quiet, do not print the match (so this doesn't spam)
      # -x means match the entire line (so macfile.cpp doesn't sneak thru
      #    via cfile.cpp)
      # -F means treat the lines patterns as fixed (not regexp)
      # -f means load patterns from the given file
          grep -qxFf used_srcs ||
      # If the grep command *fails*, then the file is not in the list.
      # Bash performs logic short-circuiting, so we can use logical-OR
        git rm $SRC;
      done
    ```

    Test Plan:
    On all three of `[win, mac, linux]`:
    ```
    cmake --preset <platform>
    cmake --build --preset <platform> --config Debug
    cmake --build --preset <platform> --config Release
    ```
2024-04-27 07:33:01 -07:00