Commit graph

9766 commits

Author SHA1 Message Date
Kp 6504853487 Use unsigned for Coop_view_player members 2017-08-13 20:38:31 +00:00
Kp aa56477742 Propagate objects_in arguments 2017-08-13 20:38:31 +00:00
Kp b4899aafac Pass vcvertptr to get_seg_masks 2017-08-11 23:43:54 +00:00
Kp 5eec2a5ce5 Use valptridx for Vertices 2017-08-11 23:43:54 +00:00
Kp c3a438b750 Pass draw_polygon_model orient by reference 2017-08-11 23:43:54 +00:00
Kp a43c5bd6d4 Remove long-dead STATION_ENABLED code
Function bm_load does not exist in current tip, 0.58.1-d2x, 0.51-d2x,
nor various early snapshots of D2X (not D2X-Rebirth, just D2X).
Attempting to enable STATION_ENABLED fails without this function.  Since
it seems to have been absent for at least 10 years (0.51-d2x tagged Feb
2007), and possibly more than 16 years (D2X snapshots from 2001), it
seems reasonable to assume no one has used this code in any open source
release.  Remove it.
2017-08-11 23:43:54 +00:00
Kp 8ed8f59d6d Fix -Wmisleading-indentation warning in SDL-only build 2017-08-11 23:43:54 +00:00
Kp 7a51b26f91 Remove obsolete serial typedefs 2017-08-11 23:43:54 +00:00
Kp 32b65ce485 Simplify storing obsolete_primary_ammo 2017-08-11 23:43:53 +00:00
Kp b028cce25b Move object ammo init into drop_powerup
This backports into Descent 1 the special-case that loads a Vulcan
cannon when it is dropped.  It also fixes a longstanding bug that a
robot that drops more than one of the powerup would fill only one of
them.
2017-08-11 23:43:53 +00:00
Kp 8c350ed5a5 Split drop_powerup path for dropping robots 2017-08-11 23:43:53 +00:00
Kp 47f1e1515a Move valptridx array typedef to appear earlier 2017-08-11 23:43:53 +00:00
Kp 1cfc8b3fbd Shrink on-stack multibuf to size of command 2017-08-11 23:43:53 +00:00
Kp 4ff9027b31 Add const-qualifiers to some multi functions 2017-08-11 23:43:53 +00:00
Kp 2a963ad077 Move multibuf into local scope
Many of these locals are wasteful, since they are always sized to the
biggest buffer required.  This is the minimal and safe solution.  Future
work will tune them to the correct size.
2017-08-11 23:43:53 +00:00
Kp 8159edd101 Use &a[i], not (a+i), to access multibuf
(a+i) form assumes that a can be used as the left hand side of
operator+().  This is true for pointers, and for C arrays that degrade
into pointers, but not for C++ std::array.  Switch to the explicit
syntax.

    git grep -lz 'multibuf+' | xargs -0 sed -i -e 's/(\s*multibuf\s*+\s*\(\w\+\),/(\&multibuf[\1],/g'
2017-08-11 23:43:53 +00:00
Kp 1e95f650aa Shorten valptridx internal names
Remove the `basic_` prefix from valptridx<T>::basic_ptr, ::basic_idx,
and ::basic_ptridx.  Since the public names are typedef aliases of these
classes, these class names appear frequently in debug information and
error messages.  The `basic_` prefix is unnecessary.  Remove it.

    git grep -lz '\<basic_\(ptr\|ptridx\|idx\)\>' -- common/include/ | xargs -0 sed -i -e 's/\<basic_\(ptr\|ptridx\|idx\)\>/\1/g'
2017-08-11 23:43:53 +00:00
Kp 34ee376c84 Add alternate valptridx error reporting mechanisms 2017-08-11 23:43:52 +00:00
Kp e42d1c540e Move single-file defines out of mission.h 2017-08-11 23:43:52 +00:00
Kp 0f9db40e36 Simplify reporting fatal errors 2017-08-11 23:43:52 +00:00
Kp 92d6234c6f Factor out thief steal sound 2017-08-06 17:25:46 +00:00
Kp 0a08c4fa06 Simplify thief primary weapon steal logic 2017-08-06 17:25:46 +00:00
Kp 03cca2b3dc Track visited segments as a local
This fixes a subtle bug where a perfectly immobile player would reuse a
previous run.  In practice, players are not immobile.
2017-08-02 02:49:13 +00:00
Kp 822249304c Remove useless unaligned write
Little endian systems stored sound as a `uint32_t`, but sent only the
lowest byte.  Store only that byte, since the destination was unaligned
and was the last field in the message.
2017-08-02 02:49:13 +00:00
Kp a6a5f7be82 Make vers_id.cpp depend on ${SOURCE_DATE_EPOCH-None} 2017-08-02 02:49:12 +00:00
Kp c9d733dd10 Add experimental Windows manifest 2017-08-02 02:49:12 +00:00
Kp 7b12619c3a Unify resource file compilation 2017-08-02 02:49:12 +00:00
Kp 7378179663 Fix __builtin_constant_p test in LTO mode
LTO allows the compiler to prove variable values that non-LTO mode
cannot prove.  The workaround for the gcc-7 __builtin_constant_p
quirk incorrectly caused LTO on older gcc to report __builtin_constant_p
as unsupported.  Fix this by adding a stub asm() statement to hide the
value of the input parameter from the compiler.

Fixes: 1ed7cec714 ("Tighten __builtin_constant_p check to handle gcc-7")
2017-08-02 02:49:12 +00:00
Kp 9205296380 Print fatal errors to console before calling hook function
On Windows, the hook function blocks until the user dismisses the
message box.  Print the message before opening the message box so that
it is available on the console, if one exists.
2017-08-02 02:49:12 +00:00
Kp a371272759 Fold obj_detach_one updates 2017-08-02 02:49:12 +00:00
Kp 7483573cdf Drop useless swaps on obsolete player_rw fields
These fields are never read, so their contents are irrelevant.  Remove
the swaps.
2017-08-02 02:49:12 +00:00
Kp c816a79c47 Always check external levels for connectivity errors
Players keep reporting errors that trace to the game rejecting invalid
data from user-made maps.  In this case, asymmetric connectivity in
_Descent Vignettes_[1] level _Stalactite Volcano_ (level 15 in Descent,
level 14 in Descent 2) caused an exception when trying to render part of
the first big room.

The debug build shipped with function `check_segment_connections` to
detect some types of connectivity errors.  Expose this function to
release builds, and call it for user-made maps.  It already checked for
asymmetric segment links.  Extend that to hotfix those links by breaking
the asymmetric connection.  Log an URGENT class message when this
happens, so that users are aware that the level was modified at load.
Move the `NDEBUG` guards into `check_segment_connections` so that
non-debug builds check only for segment symmetry, but do not check for
normals and face count errors.

[1] http://www.enspiar.com/dmdb/viewMission.php?id=724
```
sha1sum vignette.hog vignette.msn
3cd659e6dd5927b41157dfb7d1dd87d90e781f01  vignette.hog
1f7d140ffab11816364040dd6da71a1568393a16  vignette.msn

stat -c '%s %Y %n' vignette.hog vignette.msn
5717889 1251643308 vignette.hog
956 1250212930 vignette.msn
```

Reported-by: MegaDescent <http://forum.dxx-rebirth.com/showthread.php?tid=970>
2017-07-26 03:15:59 +00:00
Kp e8d82d7d85 Pass valptridx factories to static functions 2017-07-26 03:15:59 +00:00
Kp 20a61be716 Flatten serial.h type hierarchy 2017-07-26 03:15:59 +00:00
Kp 988d16c51f Clean up resolution input error handling
Revert to the user's chosen resolution, not to 0x0, which would then be
coerced to the minimum resolution.  When the text says revert, it should
revert, not just pick a size.

Change the "OK" label to say "Revert to NxM" for the resolution it is
reverting to.

Tighten input validation so that a blank width or blank height produce
the correct error message, rather than being coerced to 0, then
rejecting 0 as too small.
2017-07-26 03:15:59 +00:00
Kp eff53bfa90 Tighten OGL cache parameter validation 2017-07-26 03:15:59 +00:00
Kp 4128ce2971 Use compiler-provided integer_sequence when it is depth-efficient
Early implementations of integer_sequence used a naive implementation
that required one level of template depth per additional integer in the
sequence.  Rebirth uses a private alternate implementation named
make_tree_index_sequence that requires only log(N) steps for an
N-element index_sequence.  Recent versions of gcc ship a log(N) version
of integer_sequence.  Probe for that version and, if found, use it
instead of the private implementation, on the theory that the compiler
writers did at least as good a job as I did, and possibly better if they
were able to leverage compiler implementation details.
2017-07-26 03:15:59 +00:00
Kp 3d4d224ca9 Fix valptridx compound statement emulation on non-gcc compilers
Fixes: 53bf638c2c ("Cache valptridx success check")
2017-07-26 03:15:59 +00:00
Kp 8ccf0e5301 Add PHYSFS_read wrapper support
- Add wrappers for PHYSFS_read and its convenience functions.  Poison
  the memory before calling PHYSFS, so that any uninitialized bytes
  (likely caused by a short read) are reported if the caller tries to
  access the value anyway.
- Add SConstruct options to enable wrapping, so that users do not need
  to enumerate the wrapped functions manually.
- Fix link failure when using LTO+wrappers.
2017-07-26 03:15:58 +00:00
Kp d1c6b89f17 Move dsx::segment -> dcx::segment
d2x::segment has all members of d1x::segment, as well as two new members
exclusive to d2x::segment.  Structure layout is such that d1x::segment
requires the same size allocation, and places anonymous pad members in
the locations that become named members in d2x::segment.  Thus, reusing
d2x::segment for d1x::segment does not change the size of the structure
nor the offsets of any members used.  This reuse may enable some
functions to be better shared by the dsx project.
2017-07-26 03:15:58 +00:00
Kp 2d430596c5 Disallow misnesting for d1x+d2x, not for dsx
Future work will introduce uses of d1x/d2x in the other game when the
types can be usefully shared.  Extend the anti-nesting guards to cover
mistakes that might arise when referring to the namespaces by their
real name, rather than the alias name dsx.
2017-07-26 03:15:58 +00:00
Kp 8b713978fc Ignore bogus POF counts
Instead of blacklisting two specific bad N_save_pof_names values, ignore
all N_save_pof_names that would overrun the Save_pof_names array.

This allows Rebirth to load broken levels such as "Hazard Zone"[1].  In
the case of Hazard Zone, the POF count is simply missing, so the first
two characters of the first POF name were taken as a count.  This led to
a massive overrun of the Save_pof_names array.

[1]:
```
sha1sum hazard.msn hazard.rdl
25abe7ba1aca91f0bd09551e65cfadeabfcb73df  hazard.msn
f5e6761b674b595550b27733fd83eeb2eff5e8f8  hazard.rdl
```
2017-07-15 21:50:22 +00:00
Kp d4f1c894aa Remove write-only global Connected_segment_distance 2017-07-08 18:17:50 +00:00
Kp 30b0ebebb8 Simplify trace_seg visited update 2017-07-08 18:17:49 +00:00
Kp dc33a58225 Use array<> in more places 2017-07-08 18:17:49 +00:00
Kp a7e0e05e19 Rename vertex_array -> vertices
Future work will introduce a typedef vertex_array.  That typedef would
cause these uses to trigger a -Wshadow warning.
2017-07-08 18:17:49 +00:00
Kp 75476e0b1d Simplify D1 Countdown_timer reload 2017-07-08 18:17:49 +00:00
Kp f16c4def1d Unify AI cloak setup
- Initialize AI cloak data in D1, too.
- Initialize reactor's idea of player position from init_ai_for_ship
2017-07-08 18:17:49 +00:00
Kp 596ecbb38d Rename segment::value to segment::station_idx
`value` is generic and unclear.  It is always meant to be used as an
index into the Station array, so rename it `station_idx` to show this.

Define and consistently use `station_none` to represent that no station
is assigned.
2017-07-08 18:17:49 +00:00
Kp 6767045a41 Shrink FuelCenter::Type to uint8_t to match special from struct segment 2017-07-08 18:17:49 +00:00