Commit graph

10008 commits

Author SHA1 Message Date
Kp 08446f0ab6 Pass font to gr_string,gr_printf 2018-05-19 23:21:42 +00:00
Kp a19d4157e2 Prevent reloading cv_font in font.cpp internal functions
Callers usually have cv_font already loaded, so pass it down instead of
reloading from memory.
2018-05-19 23:21:42 +00:00
Kp 893e8cde06 Combine hud gauge parameters
Many gauge functions take the same parameters, and pass those parameters
on to child functions in turn.  Bundle common parameters into a few
standard structures, so that adding new context does not need to involve
every function in the chain for every new context value.
2018-05-19 23:21:42 +00:00
Kp f2f41cd60e Fix capitalization of MVE entries
Reported-by: ryusei117 <https://github.com/dxx-rebirth/dxx-rebirth/issues/379#issuecomment-390058146>
Fixes: 6e439e17fd ("Match case for MVE files in MVL archives")
2018-05-18 02:47:32 +00:00
Kp 784213ec1f Avoid magic strings for LazyObjectConstructor dict keys
Replace magic strings with sentinel objects, so that mistakes are
reported as missing variables, rather than being legal at parse time and
incorrect at runtime.
2018-05-17 05:30:28 +00:00
Kp 09cebc080c Undefine blank SHAREPATH
If user_settings.sharepath is configured to be blank in SConstruct, omit
the C preprocessor macro SHAREPATH instead of defining it to expand to
an empty string.  Adjust the C++ code that uses the macro SHAREPATH to
handle its absence:
- Clearer output in help text
- Skip adding blank SHAREPATH to the PhysFS search path.

As a nice side effect, this enables SHAREPATH on Windows, which could be
helpful for builds shipped with an installer that places game files in a
well-known location (such as "C:\Games\Descent").  Previously,
!defined(__unix__) systems did not add SHAREPATH to the PhysFS search
path, even when one was defined.
2018-05-17 02:49:15 +00:00
Kp 6e439e17fd Match case for MVE files in MVL archives
PhysFS 3 requires a case match.  PhysFS 2 did not.  Match the case in
the archive, which should work in both PhysFS 2 and PhysFS 3.

Reported-by: ryusei117 <https://github.com/dxx-rebirth/dxx-rebirth/issues/379>
Useful-hint-from: Manuel-K <https://github.com/dxx-rebirth/dxx-rebirth/issues/379#issuecomment-388849440>
2018-05-15 03:12:45 +00:00
Chris Taylor 0b026b6282 Fix 'Header png.h is missing or unusable' build error on macOS Xcode
Commit 131c1b9f4d added support for PNG screenshots and made this support a default build option. Set screenshot=legacy in the project file for macOS's Xcode for all out-of-the-box builds. PNG support has been dropped in Xcode for several reasons:
- macOS creates PNG screenshots via Command-Shift-3. This works in DXX-Rebirth, even in full screen mode.
- The macOS screenshots are put on the desktop, as opposed to in the user's Library (which is normally hidden from view and can only be accessed via 'Go' menu holding down Option)
- Macs have no Print Screen key
- There is no simple way to include libpng with the macOS DXX-Rebirth binaries, and the average Mac user is unlikely to install it from source

When building with scons, the Mac user compiling can do one of two things:
- Install libpng (which is much easier than packaging with a binary)
- Pass screenshot=legacy to scons
2018-05-14 15:48:00 +08:00
Kp 4a98e796ab Prevent stacking weapon rotation sounds
digi_play_sample_once is supposed to cancel prior instances of the
sound, but that functionality was lost in
21082c6db2.  As a result, the sound can be
stacked up to the limit of the engine.  Even when the functionality
existed, its implementation was wrong.

- Change these sounds to be attached to the player generating them.
- Pass the cancellation flag to other players when sending a sound.
- Send the full value of `volume`, rather than truncating it.
- Implement cancellation by killing and restarting the earlier version of a cancelled sound.
- Delete an ugly hack that prevented the patched logic from ever running.
- Fix an ancient quirk in digi_mixer that caused it to report all sounds as not playing, which then caused digi_sync_sounds to instantly cancel the new sound.

Reported-by: Mako88 <https://github.com/dxx-rebirth/dxx-rebirth/issues/88>
Reported-by: ryusei117 <https://github.com/dxx-rebirth/dxx-rebirth/issues/88#issuecomment-269597361>
Fixes: 21082c6db2 ("Added own channel management to SDL_mixer sound interface since the builtin channel management of this lib cannot handle our needs; Little code cleanup")
2018-05-13 03:14:34 +00:00
Kp 12cc5860fe Cache user's last chosen host/port for direct_join
Define global copies of the user's chosen host address, host port, and
local port.  When these are non-empty, prefer them to the values from
-udp_hostaddr, -udp_hostport, and -udp_myport.  When the user attempts a
connection, update the global copies from the user's data.  If the user
abandons the connect dialog, do not update the globals.

Requested-by: Mako88 <https://github.com/dxx-rebirth/dxx-rebirth/issues/73>
2018-05-12 21:13:05 +00:00
Kp 3796c46440 Improve default keybindings
Slide left/right: A/D
Slide up/down: C/X
Accelerate/reverse: W/S
Afterburner (D2 only): Left-Shift

This produces the more FPS-typical WASD layout for
forward/left/back/right movement, and maps the crouch/stand bindings to
slide up/down.  This ticket sat for longer than it should have (though
it never missed a release).  Several competing designs were suggested,
but only one could be made active.  After consideration, I used my own
bindings on the basis that, while some other bindings may be better,
every other configuration repurposed a classic weapons-fire key to
movement.  Returning players who get the "new defaults" on a newly
created pilot profile might be very surprised by having their fire keys
move.  Since these are only defaults, and can be rebound by the player
with a few minutes work, these defaults do not need to be perfect.  They
just need to be an improvement over original Descent.

Delete unexpand-cpp-kconfig-key.py.  It will likely never be needed, and
was added in the prior commit solely to have a file to recover if it
ever is needed.

Requested-by: Mako88 <https://github.com/dxx-rebirth/dxx-rebirth/issues/214>
2018-05-12 21:13:05 +00:00
Kp 1fd8c184fd Convert kconfig default keys to their CPP define equivalents 2018-05-12 21:13:05 +00:00
Kp e63bbe8c52 Set d_event type at construction 2018-05-12 18:24:19 +00:00
Kp fe52ddb7b6 Remove stringified enum name from WINDOW_SEND_EVENT
Future work is simpler without this, and the stringified name is only
visible in debug output, which is in turn rarely used due to its
verbosity and lack of filtering controls.
2018-05-12 18:24:19 +00:00
Kp 6ab28cb8cb Use enum for Difficulty_level 2018-05-12 18:24:19 +00:00
Kp ccc2a288f1 Simplify HUD_SCALE_X_AR, HUD_SCALE_Y_AR 2018-05-12 18:24:19 +00:00
Kp 8f1a8c9cb8 Use menu macros for change_guidebot_name 2018-05-12 18:24:19 +00:00
Kp 926a7f2a92 Remove useless const qualifier on meddraw static_cast
gcc-8 warns that static_cast<const T>(var) is useless.  Remove the const
qualifier.

References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/388>
2018-05-05 22:33:56 +00:00
Kp e69e195a3a Remove useless static_cast<float> in kconfig
gcc-8 warns that static_cast<float>(float_var + 1) is useless.  Remove
the cast.

References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/388>
2018-05-05 22:33:55 +00:00
Kp a2be4a89c9 Remove useless parentheses in gamecntl pointer-to-member declarations
gcc-8 warns for useless parentheses around the variable name.  Remove
the parentheses.

References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/388>
2018-05-05 22:33:55 +00:00
Kp 3749ee2b74 Fix cvar -Wrestrict in gcc-8
Per C99, this code was always wrong.  The results of `snprintf` are
undefined if the target string array and one of the supplied input
arguments refer to the same buffer.  In practice, this particular usage
happened to work by wastefully copying a string onto itself, then adding
more content at the end.  Switch to appending properly, which also fixes
the gcc-8 -Wrestrict warning.

References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/388>
2018-05-05 22:33:55 +00:00
Kp 6a8930cef0 Remove unnecessary inclusions of compiler-static_assert.h
Various files included compiler-static_assert.h to use the compatibility
macros for compilers that lacked a working C++11 static_assert.
However, some source files used static_assert without this inclusion,
and no one ever reported problems.  From this, assume that no one uses a
compiler which lacks C++11 static_assert.  Remove the inclusions that
were only for the compatibility macro.  Keep the inclusions that use the
assert_equal helper.
2018-05-05 22:33:55 +00:00
Kp 457022db48 Require C++11 static_assert
- Remove the one test that clang-5 still fails.
- Require all remaining tests to pass using only C++11 native
  static_assert.
- Remove preprocessor-based alternative static_assert implementations.

gcc-8 adds calls to static_assert with a comma inside its first
argument in the implementation of std::vector.  This is legal within the
standard, but conflicts with Rebirth's use of static_assert as a
two argument preprocessor macro.  The macro is not substantially useful,
and was only present to compensate for the clang limitation removed in
the previous commit.  Remove the macro.

References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/388>
2018-05-05 22:33:55 +00:00
Kp 23a899cf0e Adjust valptridx for clang static_assert limitation
valptridx contains `static_assert` statements of the form:

	static_assert(var.m, "");

where `var` is a non-`constexpr` reference and `m` is a `static
constexpr` member of a base type of `var`.  gcc recognizes that a
`static constexpr` member is a constant expression and permits this.
clang rejects this, presumably because `var` is not a `constexpr`
variable.  In the almost 3 years since this was added, clang has not
improved to permit this usage.  Rather than continuing to suppress
static_assert in clang, rewrite this expression to be less clear, but be
compatible with clang.
2018-05-05 22:33:55 +00:00
Kp d269c878b3 Add operator++,operator-- to base_bytebuffer_t
gcc-8 has special cases in its std::advance that require the target to
support `operator++` and `operator--`.  These are easy to support, so
add them.

References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/388>
2018-05-05 22:33:55 +00:00
Kp 381bfeeb5d Eliminate casts in byteutil_unaligned_copy
gcc-8 warns that static_cast<dt &>(d) is useless.  In general, it is
useless.  It is present to force a compile error in cases when `d` is
not convertible to `dt &`.  Switch to a compound statement that declares
a local reference to `d` of type `dt &`.  This achieves the same
checking effect, but does not provoke the -Wuseless-cast warning.

References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/388>
2018-05-05 22:33:55 +00:00
Kp 5cafec2268 Use enum for gauges weapon_type 2018-04-30 05:31:16 +00:00
Kp 14dac5042a Factor out count_number_of_objects_of_type predicate
count_number_of_objects_of_type is dsx due to object differences, but
the predicate can be dcx.
2018-04-30 05:31:16 +00:00
Kp 7249e4569f Adapt PCHManager to Python 3 __new__ rules
Python 2 permitted defining __new__, then deleting it once it had been
used.  Python 3 does not directly reject that pattern, but instead
always fails with an error about wrong number of arguments to object().
Switch to a simple classmethod that is explicitly invoked by the first
__init__().
2018-04-30 05:31:16 +00:00
Kp 0a5e9eb592 Adapt to Python 3 strict bytes vs str rules 2018-04-30 05:31:16 +00:00
Kp 6148327e4b Adapt configure tests to Python 3 filter API change
In Python 3, filter returns an object that can be iterated to get the
filtered content.  However, there is no way to reset the object, so it
is useless for persistence.  Spend the one iteration copying the data
into a tuple, which can be iterated multiple times.
2018-04-30 05:31:16 +00:00
Kp 8b4586bd20 Adapt PreservedEnvironment to Python 3 dictionary API changes
Python 3 `dict.keys()` returns an object that cannot be added to other
instances of itself.  Pass the returned objects as a tuple, then let the
callee use itertools.chain to combine them during iteration.
2018-04-30 05:31:16 +00:00
Kp a3d6bdd3f1 Add compatibility shims for Python 3 dictionary API change
Python 3 removed `dict.keys` and `dict.items`, then renamed
`dict.iterkeys` and `dict.iteritems` to `dict.keys` and `dict.items`,
respectively.  The iteration semantics are preferable here, so add shims
to use the iteration API under a version-appropriate name.

Change PreservedEnvironment.__getitem__ back to a class method, instead
of an instance variable.  Python 3 refuses to search the instance
dictionary for __getitem__, so the optimization of copying
`self.flags.__getitem__` to `self.__getitem__` breaks in Python 3.
2018-04-30 05:31:16 +00:00
Kp 1c0001d31d Fix parsing SConstruct file lists in Python 3
Python 3 changed the rules for list comprehensions, so the comprehension
can no longer see a class-scope variable without a class qualifier.  The
class qualifier is not legal until the class is finished.  Work around
this limitation by expanding the use inline.
2018-04-30 05:31:16 +00:00
Kp 6dd25cc064 Update num_kills_level/num_kills_total for remote kills
When a remote player destroys a robot, account it on player #0 so that
materialization centers track destroyed robots.  This is required since
player #0 is the only one to generate new robots.

Reported-by: Mako88 <https://github.com/dxx-rebirth/dxx-rebirth/issues/132>
Reported-by: Sirius-TR <https://github.com/dxx-rebirth/dxx-rebirth/issues/386>
2018-04-30 01:11:29 +00:00
Kp eec2fb39d6 Update num_kills_level/num_kills_total in multiplayer
Materialization centers ("Matcens") have a governor to prevent
overrunning the level in robots.  However, due to a logic ordering
error, multiplayer games failed to record how many robots had been
destroyed, so for the purpose of detecting whether there were currently
"too many" robots in play, the game pretended that no robots had ever
been destroyed.  Therefore, once enough robots had been created to reach
the "too many" threshold, matcens stopped generating robots, regardless
of how efficiently the player(s) had been destroying robots.

Reported-by: Mako88 <https://github.com/dxx-rebirth/dxx-rebirth/issues/132>
Reported-by: Sirius-TR <https://github.com/dxx-rebirth/dxx-rebirth/issues/386>
2018-04-30 00:54:16 +00:00
Kp 685137d5f5 Fix infinite loop in newmenu default handler
If no character matches the typed character, the loop should exit when
`lb->citem == cc`, which should happen after every entry is visited
once.  However, if no item is selected, `lb->citem == -1`, and `cc` is
never `-1`, so the exit path never triggers.  Rewrite the loop to be
bounded by number of steps, rather than bounded by returning to a
particular offset.  This also protects against undefined behavior if the
menu had zero elements.
2018-04-28 21:58:46 +00:00
Kp 3201097be8 Adjust issue template formatting 2018-04-28 04:36:11 +00:00
Kp 9be90bffde Merge pull #383 "Fix FPS." to github/master 2018-04-28 04:08:28 +00:00
Kp 861b5b5b73 Add initial draft of issue template 2018-04-27 06:09:30 +00:00
Ronald M. Clifford 6aff08408a Ensure FrameTime > 0 before starting the frame. 2018-04-26 20:27:50 -07:00
Ronald M. Clifford c514e650c3 Fix FPS locking and FPS display implementations. 2018-04-23 15:33:43 -07:00
Ronald M. Clifford a9fb3c9df9 Add missing glDisableClientState call. 2018-04-22 23:31:27 -07:00
Kp 80ee9f9249 Merge pull request #376 "Update SDLMain.m" to github/master
Reviewed-by: kreatordxx <https://github.com/dxx-rebirth/dxx-rebirth/pull/376#issuecomment-383352781>
2018-04-23 05:09:52 +00:00
Ronald M. Clifford e9d36a29c1 Fix Blocky Filtered option.
[Kp: as discussed in pull #377
<https://github.com/dxx-rebirth/dxx-rebirth/pull/377>, the previous
implementation requested a parameter combination not permitted by
OpenGL.  At best, this error was silently ignored.  Fix the error by
falling through to a switch case statement that sets valid parameters.]
2018-04-23 05:07:15 +00:00
derhass 38815ba10b change SYNC_GL_AUTO mode to disable GL sync if VSync is turned off
Users with disabled VSync might not expect any forced waiting on the GPU,
and the GL sync methods were intented to fix issues with VSync only,
so the new heuristic for SYNC_GL_AUTO is to enable GL sync only if
VSync is enabled, too.

Users can still request to use a specific GL sync method via the
-gl_syncmethod switch, independent of the VSync setting.

[Kp: folded `else { if () }` into `else if ()` to avoid moving
`ogl_have_ARB_sync` lines.  Original change visible at
<https://github.com/dxx-rebirth/dxx-rebirth/pull/381>.]
2018-04-23 04:57:48 +00:00
Ronald M. Clifford 19dbc3c13c
Fix FPS. 2018-04-22 19:28:20 -07:00
derhass 8e43a845b3 handle multiplayer network packets during SYNC_GL_FENCE_SLEEP wait loop
This mirrors the logic from calc_frame_time(). When VSync is enabled,
waiting for the previous frame to complete might induce long wait periods,
up to the complete frame time, so we should also handle multiplayer there.

For the other sync modes, the GL calls will simply block, so we can't do
anything about that (except going multithreaded, but that's a totally
different can of worms). Note that even without sync, the SwapBuffers()
call in gr_flip() may also block if VSync is on (and enough frames are
queued up), so the issue is not the GL sync code itself.

SYNC_GL_FENCE_SLEEP is now probably the nicest mode for multiplayer
with VSsync, as it is the only one which has the potential to continue
handling multiplayer packets during the wait for VBlank time.
2018-04-22 18:14:34 +02:00
C.W. Betts c4417aafb1 Update SDLMain.m:
10.9 changed how applications were launched, making the old method of detecting a Finder launch fail.
2018-04-16 16:19:36 -06:00
Kp fca9750105 Add utility script for converting HAM to/from json
This script was written years ago and has sat unused since then.
Recently, someone asked for a copy, so I may as well publish it.  The
HXM support may not have been tested, but the base HAM support can
successfully deconstruct Vertigo and reassemble a bit-wise identical
copy.
2018-04-15 21:48:32 +00:00