This eliminates the only place that zip<>'s template parameter list is
written out in the source, which will allow later commits to change the
template parameter list.
Checking the glow special case should be cheaper than computing and
checking the normal, so check the glow case first. Also, when the glow
values are defined, cache the result of reading from it to avoid
repeating the indexing logic farther down.
This makes the alignment data structure `chunk` private to interp.cpp,
and allows most files to ignore whether DXX_WORDS_NEED_ALIGNMENT is
enabled, thus improving the ccache hit rate.
Descent 1 mangles colors during `g3_init_polygon_model`, so this must
not be called on polygons not designed for mangling. Rearrange the
logic to allow Descent 1 to verify that polygon models are well-formed
without using the functions that mangle the colors.
Fixes: 42a2e3ab0b ("Avoid crash loading polymodels with invalid subcalls")
Reported-by: derhass <https://github.com/dxx-rebirth/dxx-rebirth/issues/416>
Windows std::ptrdiff_t is `int` instead of `long` as it should be.
Expand the values out to `long` (which is the same size as `int` on
Win32!) before printing them. This fixes format string warnings.
Reported-by: Ninjared <https://forum.dxx-rebirth.com/showthread.php?tid=857&pid=12555#pid12555>
Fixes: 42a2e3ab0b ("Avoid crash loading polymodels with invalid subcalls")
For each link given as http://, verify that the site is accessible over
https:// and, if so, switch to it. These domains were converted:
* llvm.org
* clang.llvm.org
* en.cppreference.com
* www.dxx-rebirth.com
* www.libsdl.org
* www.scons.org
Only one caller exists, and that caller alway passes a non-nullptr
value. Switch to a reference and remove the unused special case to
handle a nullptr input.
Past releases had a debug-only assertion that 25 was sufficient, but
then dynamically allocated enough storage for larger models as needed.
Commit 22a34809ee ("Move interpreter g3s_lrgb onto stack") added a
hard limit of 25, but did not detect attempts to exceed this. Custom
models that exceeded 25 would cause a stack buffer overwrite and likely
crash. Raise the limit to 64 and add sanity checking to refuse to
render models that exceed MAX_POINTS_PER_POLY.
Fixes: 22a34809ee ("Move interpreter g3s_lrgb onto stack")
Rename symbol WORDS_NEED_ALIGNMENT to DXX_WORDS_NEED_ALIGNMENT to show that it is a DXX
symbol, not one inherited from a library.
This is a mostly automated transform, but the changes to SConstruct were
manual.
git grep -wl WORDS_NEED_ALIGNMENT -- '*.h' '*.cpp' | xargs sed -i -e 's/^\s*#ifdef \(WORDS_NEED_ALIGNMENT\)\>/#if DXX_\1/' -e 's/\s*#\(el\)\?if \(.*\)defined(\(WORDS_NEED_ALIGNMENT\))/#\1if \2DXX_\3/' -e 's/^\s*#ifndef \(WORDS_NEED_ALIGNMENT\)\>/#if !DXX_\1/'
Rename symbol WORDS_BIGENDIAN to DXX_WORDS_BIGENDIAN to show that it is a DXX
symbol, not one inherited from a library.
This is a mostly automated transform, but the changes to SConstruct were
manual.
git grep -wl WORDS_BIGENDIAN -- '*.h' '*.cpp' | xargs sed -i -e 's/^\s*#ifdef \(WORDS_BIGENDIAN\)\>/#if DXX_\1/' -e 's/\s*#\(el\)\?if \(.*\)defined(\(WORDS_BIGENDIAN\))/#\1if \2DXX_\3/' -e 's/^\s*#ifndef \(WORDS_BIGENDIAN\)\>/#if !DXX_\1/'
Optimizing compilers tend to factor out color automatically. Move it up
to the caller to ensure that it is computed once even if the compiler
does not optimize aggressively.
Rename symbol EDITOR to DXX_USE_EDITOR to show that it is a DXX
symbol, not one inherited from a library. Move it to dxxsconf.h to
shorten the command line.
This is a mostly automated transform, but the changes to SConstruct were
manual.
git grep -wl EDITOR -- '*.h' '*.cpp' | xargs sed -i -e 's/^\s*#ifdef \(EDITOR\)\>/#if DXX_USE_\1/' -e 's/\s*#\(el\)\?if \(.*\)defined(\(EDITOR\))/#\1if \2DXX_USE_\3/' -e 's/^\s*#ifndef \(EDITOR\)\>/#if !DXX_USE_\1/'
This pass only targets commonly used standard types.
s/(\(\s*\(\(un\)\?signed\|int\|char\|short\|long\|float\|double\|s\?size_t\|\(u\?int[[:digit:]]\+_t\)\)\)\s*)\s*(/static_cast<\1>(/g
C casts do not require parentheses. C++ casts require grouping around
the target. Prepare for conversion to C++ casts by adding otherwise
unnecessary parentheses around the target of simple C casts.
This pass does not attempt to process expressions that involve
any subexpression that can nest arbitrarily, such as parentheses or
brackets. It also works only on commonly used standard types.
(int) a->b; // changed
(int) a[b]; // not changed
s/\((\s*\(\(un\)\?signed\|int\|char\|short\|long\|float\|double\|s\?size_t\|\(u\?int[[:digit:]]\+_t\)\)\s*\**\s*)\s*\)\([&+-]\?\)\([[:alnum:]_.]\+\s*->\s*\)*\([[:alnum:]_.]\+\)\(\s*\([];+>)*\/^%,|&<>]\)\|$\|\(\s*-\s*[^>]\)\)/\1(\5\6\7)\8/g
get_chunks_state has a member named `data` and its constructor took a
parameter named `data`. This is unambiguous in the language, but causes
a warning from gcc's -Wshadow when building with WORDS_NEED_ALIGNMENT.
Rename the parameter to eliminate the warning.
Reported-by: derhass <https://github.com/dxx-rebirth/dxx-rebirth/pull/196>