Commit graph

4497 commits

Author SHA1 Message Date
Kp 7c0cdd6c51 Fix crash loading Vertigo briefing
Commit 1335af4b51 restructured briefing number parsing, but
unintentionally changed the parser not to drop the newline after a
number.  The briefing parsing code is very sensitive to minor changes,
so this broke parsing some briefing screens, including Vertigo briefing
screens after the first.  After the change, clicking through the Vertigo
briefing aborts on failure to load a PCX file.

Fix this by consuming the newline before returning.  This matches the
previous semantics.

Reported-by: Havner <https://github.com/dxx-rebirth/dxx-rebirth/issues/343>
Fixes: 1335af4b51 ("Simplify get_message_num")
2017-09-08 00:56:37 +00:00
Kp 456e239ae3 Use reference for ai_local 2017-09-08 00:56:37 +00:00
Kp 0548384d2a Fix excessive lavafall damage
Like many things in the main game loop, lavafall handling was
historically done on a per-frame basis, then its effects were scaled to
FrameTime to normalize the results.  Ignoring rounding errors, this
produced roughly equivalent damage for high framerate users (who
experienced many but small damage hits) and low framerate users (who
experienced few but large damage hits).  However, the randomized
movement was not scaled to FrameTime, which caused differing results for
high framerate users versus low framerate users.  Commit b36c6f20c7
tried to fix this by forcing scrape_player_on_wall to run at a capped
maximum effective frame rate, then scaling the damage in
check_volatile_wall accordingly, so that high framerate users would
experience fewer damage hits, but the ones they received were larger,
thus maintaining approximately the same damage as before.

Prior to b36c6f20c7, damage was always scaled to FrameTime.  In
b36c6f20c7 and later, damage scaled to max(FrameTime,
DESIGNATED_GAME_FRAMETIME), causing users with a high frame rate (and
thus low FrameTime) to take more damage on each pass.  This damage
increase was balanced by an added hack in scrape_player_on_wall to limit
the frequency of the scrape so that high framerate users would skip some
scrapes, giving them a virtual frame rate appropriate to
DESIGNATED_GAME_FRAMETIME.  However, the damage is only balanced if the
new governor is used consistently.  It is not used consistently, so it
caused a regression for passable lava surfaces.  Scraping on a solid
lava surface goes through scrape_player_on_wall and respects the
governor.  Touching a passable lava surface (only available in Descent
2) bypasses scrape_player_on_wall and jumps directly to
check_volatile_wall, thereby bypassing the governor.  This allows high
framerate users touching a passable lava surface to take many hits (as
they always did), but not receive the full benefit of downward scaling
the damage (as they once did) due to the new max() expression.  Thus,
they are damaged frequently, but still take damage consistent with being
damaged infrequently.

Fix this by moving the hack from scrape_player_on_wall to
check_volatile_wall, so that both solid lava surfaces and passable lava
surfaces respect the governor.  The governor is still an ugly hack that
should not be global, but this is a spot fix for the immediate problem.

Fixes: b36c6f20c7 ("Made scrape_player_on_wall() based on a timer. Due to the player being pushed away from the lava/water surface in every frame in a random vector (wrong, too), player movement per frame was not enough to counter this on FPS rates > ~120 which made damage scaling per frame nonsensical in these situations. Instead, execute scrape results in intevals based on DESIGNATED_GAME_FRAMETIME (or per frame if FrameTime>DESIGNATED_GAME_FRAMETIME) which fixes the issues and generally works much better for the purpose of this function.")
2017-09-08 00:56:37 +00:00
Kp aeedadba89 Unify D1/D2 scrape_player_on_wall 2017-09-08 00:56:37 +00:00
Kp a24490033f Allow players to remove thief at level start
Commit f4b21088a0 ("Track vulcan ammo explicitly") fixed an original
retail bug that prevented the thief from stealing energy weapons,
because the thief could only steal weapons for which the player had ammo
and energy weapons never have ammo.  This went unremarked for several
years, until a recent report of the new semantics as a game-breaking
regression because the thief is now "ridiculously potent".

Address this report, as well as an intermittently raised issue from
various users over time, by adding two new knobs to both the single
player "Gameplay" menu and the multiplayer setup screen: "Remove Thief
at level start" and "Prevent Thief Stealing Energy Weapons".

"Remove Thief" deletes the thief object during level load.  It has no
impact on save games, and changing it after entering a level has no
effect on any thief already in the level.

"Prevent Thief Stealing" is checked at the moment of theft and, when
enabled, prevents stealing primary weapons other than Vulcan/Gauss.
This can be changed at will in single player and is immediately
effective.  In multiplayer, this option can only be changed by the game
host in the pre-game setup.

For both knobs, there is one pair of checkboxes to control this as a
player preference, which applies in single player games.  There is a
second pair of checkboxes in the multiplayer setup, which applies only
to multiplayer games.  Therefore, in multiplayer, the host chooses thief
settings and all clients use the host's choice.  The host may configure
the thief differently in multiplayer from how the host plays in single
player.

For users who wanted to remove the thief, no specific tally has been
kept for who requested it or when.  Now that the code is being updated,
this is thrown in as an easy addition.

Reported-by: MegaDescent <http://forum.dxx-rebirth.com/showthread.php?tid=980> (for the thief stealing energy weapons as a game-breaking regression)
2017-08-26 19:47:52 +00:00
Kp 4ea9ef5b0c Use reference for robot_info 2017-08-26 19:47:51 +00:00
Kp 3bcee35c7b Shrink some Netgame fields
For protocol compatibility, zero-pad the outbound messages.  Previously,
the upper bits were zero because the value fit in a byte.
2017-08-26 19:47:51 +00:00
Kp 3340a6c16c Report compiled/loaded library versions at verbose level
When reporting use of SDL_mixer, report its loaded version.  When
running in verbose mode, report both the compile-time and load-time
versions of PhysFS, libSDL, and SDL_mixer.
2017-08-26 19:47:51 +00:00
Kp 6b209c8713 Decorate OpenGL messages
Some Linux libraries print their own messages to stdout/stderr,
particularly in case of severe errors.  Decorate messages generated by
Rebirth to distinguish them from library generated messages.

For specific blacklisted renderers, add a message informing the user
that the blacklist matched and changed settings.
2017-08-26 19:47:51 +00:00
Kp b5b5cbd4d7 Pass canvas to meddraw draw_listed_segments 2017-08-26 19:47:51 +00:00
Kp 9e917e4c7d Pass canvas to meddraw draw_segment 2017-08-26 19:47:51 +00:00
Kp d81e7862f0 Pass canvas to meddraw draw_line 2017-08-26 19:47:51 +00:00
Kp 88430e8946 Require vms_angvec &for g3_start_instance_angles
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.
2017-08-26 19:47:51 +00:00
Kp 1831148092 Split g3_start_instance_matrix usage
Most uses pass an orientation matrix.  All sites are deterministic about
whether a matrix is passed.  Make the matrix mandatory for sites that
passed it, and split out a separate version of g3_start_instance_matrix
for the 2 sites which do not provide orientation.
2017-08-26 19:47:51 +00:00
Kp b65b6339f4 Make g3_draw_sphere pnt argument const (for OGL only)
SDL still needs to modify it, so use alias type `cg3s_point`, which is
`const g3s_point` in OGL and `g3s_point` in SDL.
2017-08-16 01:54:26 +00:00
Kp f114757208 Fix D1 build of similar/main/newdemo.cpp
Fixes: e859833f62 ("Use valptridx for Players")
2017-08-16 01:54:26 +00:00
Kp 4cec183386 Fix pch=0 build of similar/main/mglobal.cpp
Fixes: e859833f62 ("Use valptridx for Players")
2017-08-16 01:54:26 +00:00
Kp e859833f62 Use valptridx for Players
Currently, N_players is still a free variable and Players.count is
unused.  Future work will replace N_players with Players.count.
2017-08-13 20:38:32 +00:00
Kp 8b93c6a283 Make Bounty_target unsigned 2017-08-13 20:38:32 +00:00
Kp e18b95201c Tighten hoard record holder validation 2017-08-13 20:38:32 +00:00
Kp 4cf4ce38b0 Cache player references 2017-08-13 20:38:31 +00:00
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 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 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 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 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 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 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 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 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 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