Commit graph

114 commits

Author SHA1 Message Date
Kp fbc184500d Use explicitly defaulted operator== for vms_vector 2022-10-09 23:15:19 +00:00
Kp d797072596 Make vector magnitude constant in more cases
Introduce a helper to obtain both the magnitude of a vector and the
corresponding normalized vector.  Use it to capture both values as const
when possible.
2022-09-24 17:47:52 +00:00
Kp 62635ec285 Use enum class for vm_magnitude_squared 2022-05-24 02:32:58 +00:00
Kp b8a8a61ff8 Simplify multiplayer powerup creation
Instead of creating the powerup from a player, then overwriting the
location and velocity of the powerup, and fixing up its segment, create
the powerup directly where it should be, with the intended velocity.
2022-01-09 15:25:42 +00:00
Kp e1aac6949a Replace __attribute_warn_unused_result with C++17 [[nodiscard]]
This eliminates a configure test, and may help readers understand the
annotation more readily.
2021-06-28 03:37:51 +00:00
Kp 3e25804026 Use NSDMI wherever possible 2019-04-28 00:53:40 +00:00
Kp 08e4a6e620 Use stdint constants for some INT*_MAX
clang becomes confused trying to determine which vm_distance_squared
constructor to use for a literal input of 0x7fffffffffffffff, even
though the size of the input requires it to be `long` and only one
constructor can take a `long`.  Switch from an explicit
0x7fffffffffffffff to the symbolic constant INT64_MAX, which has the
same value, but a platform-appropriate suffix to force the compiler to
pick the right type.

For general clarity, switch some other instances of integer maximum
literals to symbolic constants of the same value.

This commit has no effect on the generated code (except for changes to
line numbers).

Reported-by: kreatordxx <https://github.com/dxx-rebirth/dxx-rebirth/pull/324>
Fixes: 17208cca79 ("Disallow int for vm_distance_squared")
2017-02-22 03:05:43 +00:00
Kp 17208cca79 Disallow int for vm_distance_squared 2017-02-11 21:42:43 +00:00
Kp 3a4eafac03 Add workaround for passive thief bot
zicodxx reports that f7d0c85 made the thief bot passive and timid.
His analysis suggests that the problem is because f7d0c85 changed
find_connected_distance to return vm_distance::maximum_value() in places
where it previously returned magic values that were not maximum (caching
a distance of F1_0*1000 and returning a distance of -1).  Rather than
try to fix the underlying code that relied on these magic values, revert
those return paths to return these unusual values.  Move the unusual
values to named constants in file scope so that they are easier to find
and correlate.

Reported-by: zicodxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/286>
Analyzed-by: zicodxx

Fixes: f7d0c853ba ("Use special types for distance/magnitude")
2016-12-29 03:27:14 +00:00
Kp 5f33054161 Hide vm_distance safety net from clang
When the safety net is present, clang becomes confused.  Run without a
net and hope that gcc users catch any erroneous conversions.
2016-02-02 03:10:53 +00:00
Kp 4abbc28d0f Switch to non-template operator> for vm_distance
clang considers the template form to be ambiguous
2016-01-27 04:01:55 +00:00
Kp dc8c0323d8 Uninline namespace dcx 2015-12-13 18:00:49 +00:00
Kp cfc35e819d Use inline namespace dcx for common/maths 2015-12-05 22:57:24 +00:00
Kp 32c7214f5a Add vecmat forward declaration header 2015-12-05 22:57:23 +00:00
Kp e5683593ef Expand ZERO_VECTOR inline 2015-08-13 03:15:53 +00:00
Kp 4f871c43fe Add compile-time check for non-overlapping vm_matrix_x_matrix 2015-08-13 03:15:52 +00:00
Kp 4d8ae44794 Add helper macro DXX_CONSTANT_TRUE 2015-07-29 03:05:28 +00:00
Kp c9dff229f1 Remove dead AI fire leading code 2015-07-25 23:10:47 +00:00
Kp a918692a23 Preprocess out EDITOR-only vm_vec_ang_2_matrix
Remove vm_vec_ang_2_matrix from non-EDITOR builds so that
sincos_2_matrix has only one caller, allowing compiler to implicitly
inline it.
2015-06-02 03:03:32 +00:00
Kp e30e0ebb94 Shorten vm_vec_copy_scale 2015-04-29 03:35:09 +00:00
Kp 23364a5862 Remove warn_unused_result from vm_vec_normalize
Some callers want the side effect of normalizing the argument and do not
need the magnitude.  Per report from btb, the warning broke the OS X
build.

Reported-by: btb <5e4bd5c73f (commitcomment-10899878)>
Fixes: 5e4bd5c73f ("vm_vec_delta_ang: check for vm_vec_copy_normalize failure")
2015-04-25 16:56:25 +00:00
Kp 5e4bd5c73f vm_vec_delta_ang: check for vm_vec_copy_normalize failure
derhass reports that Raspbian g++-4.8.2 rejects vecmat.cpp for
-Wmaybe-uninitialized on t0, t1.  Fix it by adding code to return 0 if
vm_vec_copy_normalize leaves the temporary uninitialized.

Reported-by: derhass <https://github.com/dxx-rebirth/dxx-rebirth/issues/55>
2015-04-03 02:46:25 +00:00
Kp 7045b44386 Move operator*(vm_distance,vm_distance) into class scope
clang -Wunused-function warns about a 'static constexpr' function
defined in a header if the header is ever included in a file which does
not call the function.  Move the function into class scope to silence
the warning and prevent the compiler from considering it when resolving
operator*(T1,T2).

Reported-by: btb <https://github.com/dxx-rebirth/dxx-rebirth/pull/54#issuecomment-86252750>
2015-03-26 02:42:26 +00:00
Kp 76d383261c Return vm_distance_squared from check_vector_to_sphere_1 2015-03-12 02:21:20 +00:00
Kp 2c09f9fa90 Propagate special types for distance/magnitude 2015-03-12 02:21:19 +00:00
Kp f7d0c853ba Use special types for distance/magnitude 2015-03-12 02:21:19 +00:00
Kp 673a711461 Remove vm_angles_2_matrix return value 2015-02-05 03:03:51 +00:00
Kp d1f5695562 Remove unused return value of vm_vec_scale_add 2015-02-03 00:37:08 +00:00
Kp 2026ab7e3a Remove unused return value of vm_extract_angles_vector 2015-02-03 00:37:08 +00:00
Kp 656c51fa99 Remove unused return value of vm_vec_rotate 2015-02-03 00:37:08 +00:00
Kp 505a3dbae7 Remove unused return value of vm_vector_2_matrix 2015-02-03 00:37:07 +00:00
Kp c6f95c5880 Remove unused return value of vm_vec_normal 2015-02-03 00:37:07 +00:00
Kp 52267b87b9 Remove unused return value of vm_vec_cross 2015-02-03 00:37:07 +00:00
Kp aa75eb212c Remove unused return value of vm_vec_perp 2015-02-03 00:37:07 +00:00
Kp 055f9593de Remove unused return value of vm_vec_scale2 2015-02-03 00:37:07 +00:00
Kp cca8fd65a1 Remove unused return value of vm_vec_scale_add2 2015-02-03 00:37:07 +00:00
Kp e0bf0be779 Remove unused return value of vm_vec_add2 2015-02-03 00:37:07 +00:00
Kp e14440b0e0 Remove unused return value of vm_vec_sub2 2015-02-03 00:37:07 +00:00
Kp cd7e99981b Remove unused return value of vm_vec_avg 2015-02-03 00:37:07 +00:00
Kp ff493fcfce Inline vm_vec_make 2015-01-12 00:26:02 +00:00
Kp fda3fc33f3 Skip unnecessary sqrt for omega cannon 2014-11-11 04:25:47 +00:00
Kp e2741ce899 Add vm_extract_angles_matrix that returns result 2014-11-04 01:32:43 +00:00
Kp df6b4bd783 Add vm_vec_rotate that returns result 2014-11-04 01:31:22 +00:00
Kp 3a24b20e15 Add vm_vector_2_matrix that returns result 2014-11-04 01:27:55 +00:00
Kp 141a7602d0 Add vm_angles_2_matrix that returns result 2014-11-04 01:24:08 +00:00
Kp fed5d0e90f Add vm_vec_perp that returns result 2014-11-02 03:44:27 +00:00
Kp d76e259db5 Add vm_vec_cross that returns result 2014-11-02 03:44:12 +00:00
Kp 40eb2e6b01 Add vm_vec_scale_add that returns result 2014-11-02 03:43:57 +00:00
Kp b32f5e5df3 Add vm_vec_copy_scale that returns result 2014-11-02 03:43:47 +00:00
Kp 697bdcf078 Add vm_vec_normal that returns result 2014-11-01 03:17:48 +00:00