Commit Graph

41 Commits

Author SHA1 Message Date
Louis Gombert
ae5840f314
Merge pull request #502 from winterheart/modules-split
Splitting submodules of project
2024-07-30 23:17:47 +02:00
Louis Gombert
fc2268d629 DMFC: declare external DMCFStringTable, DMFCStringTableSize, _DMFCErrorString, basethis and DMFCGetString only when needed 2024-07-28 17:52:01 +02:00
Azamat H. Hackimov
b9da6b59ff Isolate physics module
Update physics module, minor cleanups, remove unused code.
2024-07-28 16:50:42 +03:00
Azamat H. Hackimov
7b31572d05 Isolate grtext submodule
Isolate grtext from rest of the project, minor cleanups.
2024-07-28 16:50:42 +03: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
Azamat H. Hackimov
45aa389f68 Move content from dmfcdllinit.h
Simplify code.
2024-07-08 11:15:18 +03:00
Azamat H. Hackimov
0bae89dd05 Fix runtime error on creating multiplayer game
Update dll typedefs to reflect cfile API changes.
2024-07-08 11:15:18 +03:00
Azamat H. Hackimov
59487976f6 Isolate misc module
Isolate misc module for better dependency handling.
2024-06-27 01:26:35 +03:00
Thomas Roß
113e7eaaaa [DMFC] Removed preprocessor definition DMFC_DLL and related code, because we build DMFC as static lib and don't need any of that dllexport/import stuff anymore. 2024-06-16 16:56:20 +02: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
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
cc67b9230a Replace "signed short" with "int16_t" 2024-05-23 23:04:15 -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
Louis Gombert
72c0a46dcc Fix -Wnull-conversion using explicit false 2024-05-15 00:18:44 +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
C.W. Betts
8d3b2f8877
C++ Algorithm pokes (#304)
* Use std::max and std::min, with an initializer_list where possilbe.

* Use std::clamp where appropriate.

* Missed a couple of them.

* Remove clamp specializations at @Lgt2x suggestion.
2024-05-08 11:04:52 +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
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
Louis Gombert
04e8aeb247 Fix -Wswitch 2024-04-21 20:24:31 +02:00
Thomas Otto
00389c50ea Some more CMake white space formatting
- tabs to spaces
 - use Unix line endings everywhere
 - newline at end of file
 - remove trailing white space
 - no space between keywords and opening parenthesis
 - use 2 spaces to indent
2024-04-21 11:46:32 +02:00
Kevin Bentley
1f45163248 Updated source to reflect the license that this code is released under. 2024-04-20 09:57:49 -06:00
Thomas Otto
bd0122e5af Use PInfo* instead of void*
This avoids a lot of casts back to this (and ever only this) type.
2024-04-20 16:33:22 +02:00
Louis Gombert
c2b71b8147 Standardize CMake formatting
lowercase function names, blocks indent
2024-04-20 14:45:49 +02:00
C.W. Betts
57078ae4b5 Change most sprintf to snprintf.
This also includes vsprintf to vsnprintf.
2024-04-19 12:31:28 -06:00
Thomas Otto
b909a4cf43 Convert min/max macros to std::min/max
Added explicit <float> or <int> template argument where needed.
Add -DNOMINMAX define for Windows.
2024-04-17 21:43:38 +02:00
Azamat H. Hackimov
38128ea134 Additional clang-format 2024-04-17 00:25:04 +03:00
Kevin Bentley
61be1317b2 More clanging 2024-04-16 14:46:12 -06:00
Kevin Bentley
7399b5a2f2 Fix CRLF line endings. 2024-04-16 14:21:35 -06:00
Dan Raviv
9fdf9c63b7 Adjust rudimentary randomness to avoid assuming pointer size is 32 bits 2024-04-16 13:02:45 -07:00
Kevin Bentley
c6640cc631 clang-format on everything. 2024-04-16 12:56:40 -06:00
Kevin Bentley
df209742fc Initial import 2024-04-15 21:43:29 -06:00