Added installation steps for all built targets. Added FORCE_PORTABLE_INSTALL cmake option that controls portable installation (only supported for now).
Before this change, users would have to jump through hoops in order to
make sure that they’re using the .d3m files from this repo (as opposed
to the .d3m files that came with their version of Descent 3).
Specifically, users would have to remove or backup Descent 3’s original
netgames/ directory, create a new one, hunt down TCP_IP.d3c and copy it
to the new netgames/ directory.
This change makes it easier for users to use the latest version of
working by creating a netgames/ directory for them. All they have to do
is replace the old one with the new one.
Fixes#369.
Functions declared in idmfc.h were prefixed by both macros `EXTERN` and `DLLEXPORT`. `EXTERN` expands to `extern "C"` for C++ code, and `DLLEXPORT` expands to `extern "C"` for C++ or `extern` for C code, making up two `extern` qualifiers for C++ code. We now only use DLLEXPORT macro.
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.
* 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.
* 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.
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.
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
```
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
```
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
```
- 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
Most of the warnings were caused by uninitialized values. Some were in plug-ins that didn't have a break in a switch, causing the memory to be deleted twice.