Commit graph

3145 commits

Author SHA1 Message Date
Kp 2cac55d6c7 Raise max marker limit to 4 for cooperative games 2018-03-10 22:45:04 +00:00
Kp 49a4ac1c0e Move more marker state to d_marker_state 2018-03-10 22:45:04 +00:00
Kp 4d6b796874 Store MarkerObject as imobjidx, not objnum 2018-03-10 18:32:02 +00:00
Kp 7dee4ca49f Move MarkerMessage[] into wrapper d_marker_state
Also, fix an ancient bug with the automap handling of markers caused by
WET anti-pattern.
2018-03-10 18:32:02 +00:00
Kp ca2b1e0cf0 Remove build_colormap_good parameter used
`build_colormap_good` only took `used` to clear it.  Only one caller
needed it cleared.  Move the clear into that caller.  Remove the
parameter from all calls.
2018-03-08 04:21:18 +00:00
Kp b6e2205b9f Simplify palette color tracking
Callers only care whether a color is used, not how often it is used.
2018-03-08 04:21:18 +00:00
Kp 852ab312d5 Remove global Network_laser_track 2018-03-05 01:40:44 +00:00
Kp 131c1b9f4d Add support for PNG screenshots 2018-02-18 00:42:42 +00:00
Kp d469bcbe24 Guard event_get_idle_seconds in #if DXX_USE_EDITOR
Only editor code accesses this variable.  Skip tracking it in non-EDITOR
builds.
2018-02-10 22:23:36 +00:00
Kp b1d9c2dd51 Document valptridx error reporting dispatch macro 2018-02-04 01:56:40 +00:00
Kp 22fe81666a Unify some control_info fields 2018-01-29 01:56:40 +00:00
Kp 1ffefa3029 Use partial_range for robot_get_anim_state 2018-01-29 01:56:40 +00:00
Kp d2612734a3 Fix compile error for !DXX_HAVE_CXX_BUILTIN_FILE_LINE
If !defined(DXX_HAVE_CXX_BUILTIN_FILE_LINE), the default value is
omitted, but the comma between values is still required.  The comma was
incorrectly guarded, so it was present only when a default value was
set.

Reported-by: kreatordxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/361>
Fixes: 544fc0f893 ("Add support for increased precision of gamelog timestamps")
2017-12-27 05:39:07 +00:00
Kp 544fc0f893 Add support for increased precision of gamelog timestamps
- Enable display of subsecond (Linux: microseconds; Windows:
  milliseconds) precision on gamelog timestamps.
- Add disabled support for YYYY-MM-DD leaders on gamelog timestamps.
  Activate it by defining DXX_CONSOLE_TIME_FORMAT_YMD to true.
- Add disabled support for capturing caller __FILE__, __LINE__ in calls
  to con_printf, con_puts.  Activate it by defining
  DXX_CONSOLE_SHOW_FILE_LINE to true.  If captured, write those to
  gamelog after the timestamp and before the text.  This feature (and
  only this feature) requires that DXX_HAVE_CXX_BUILTIN_FILE_LINE be
  defined, which is conditional on if the compiler has __builtin_FILE()
  and __builtin_LINE().  If the compiler lacks this support, attempts to
  enable this feature are ignored.
- Switch to using GetLocalTime on Windows.
2017-12-06 05:14:32 +00:00
Kp 01e1b28d71 Replace useless printf with puts 2017-12-05 05:29:55 +00:00
Kp 9ba159366e Eliminate macro for con_puts
Use a universal reference and type traits to identify which strings can
be measured at compile time.
2017-12-05 05:29:55 +00:00
Kp 7311712399 Compile out joystick key settings when DXX_MAX_JOYSTICKS=0 2017-12-05 05:29:55 +00:00
Kp c60c0352f0 Fix songs_play_file use for sdlmixer=0 2017-11-25 01:56:51 +00:00
Kp d42fff397b Fix Windows exception log short stack
The Windows exception handler probes the stack to determine how much can
be safely dumped, up to a fixed maximum number of bytes.  A logic error
caused the probe function to start its stack probe lower than intended,
so the eventual dump code logs fewer pre-exception bytes than intended.
Fix that error so that the dump shows more pre-exception bytes.

Also, log the address of the ud2 instruction, so that the effective load
address of the module can be determined.  Without this, ASLR makes
reading the dumps needlessly difficult.
2017-11-18 04:45:50 +00:00
Kp ff49e949d4 Fix savegame thumbnail previews
Transposed arguments to fill_n caused rls_stretch_scanline to write
garbage to the preview buffer.

Reported-by: Havner <https://github.com/dxx-rebirth/dxx-rebirth/issues/354>
Fixes: 8aadb4be5b ("Use fill_n instead of inline loop to write scanline")
2017-11-06 04:24:16 +00:00
Kp 09963e8b5a Remove write-only Seg_scale 2017-11-05 20:49:09 +00:00
Kp 7eadc218a6 Add debugging code to trace global canvas updates 2017-11-05 20:49:09 +00:00
Kp d049f738c8 Convert various gr_set_current_canvas calls to reference form 2017-11-05 20:49:08 +00:00
Kp 4f40b9de18 Assert that a canvas is not referenced when it is destroyed 2017-11-05 20:49:08 +00:00
Kp 49c0cdae2e Simplify calls to gr_set_default_canvas
Rather than use an inline wrapper and rely on the compiler optimizer to
redirect gr_set_current_canvas(nullptr) to gr_set_default_canvas,
rewrite all relevant calls directly in the source.

git grep -l 'gr_set_current_canvas' | xargs sed -i -e 's:gr_set_current_canvas(\s*NULL\|nullptr\s*);:gr_set_default_canvas();:'
2017-11-05 20:49:08 +00:00
Kp b7641e17eb Hide PF_UVS,PF_LS from OGL build
Only the SDL build uses them.  Preprocess them out of the OGL build.
2017-11-05 20:49:08 +00:00
Kp 6043168d51 Move various SDL-only texture mapping functions to !DXX_USE_OGL
The OGL build compiles, but does not use, various texture mapping
functions.  Move these to be built only for the SDL build.
2017-11-01 02:01:21 +00:00
Kp 87686e5962 Pass fade value to c_tmap_scanline_shaded as a parameter
Writing it to a global so that the called function can immediately read
it back is wasteful.  Pass it as a parameter.
2017-11-01 02:01:21 +00:00
Kp 5d4d3347e6 Remove unused found_poly 2017-11-01 02:01:20 +00:00
Kp 3fbc710ec5 Move various SDL-only scanline functions to !DXX_USE_OGL
The OGL build compiles, but does not use, various scanline functions.
Move these to be built only for the SDL build.
2017-11-01 02:01:20 +00:00
Kp 8684cf5571 Remove unused gr_bitblt_dest_step_shift
It is always 0, and has been since it was imported in D2X.
2017-11-01 02:01:20 +00:00
Kp 5e563ca3c0 Remove unused OGL c_tmap_scanline_per
scanline.cpp defined two implementations, one in a `#if 1` and the other
in an else.  Keep the enabled one.  Delete the other.
2017-11-01 02:01:20 +00:00
Kp aa6ca60a03 Remove unused OGL c_tmap_scanline_lin
Keep the SDL c_tmap_scanline_lin, which is used.
2017-11-01 02:01:20 +00:00
Kp 8d80300e0a Remove obsolete D1 hostage editor code
This code was part of a feature abandoned before retail.  It cannot be
usefully used in campaigns.  Remove it to reduce code size and simplify
later changes.
2017-10-14 17:10:31 +00:00
Kp 88832e3679 Use constexpr integral_constant for various magic numbers 2017-10-14 17:10:30 +00:00
Kp 666539b88f Define valptridx factory typedef earlier 2017-10-14 17:10:30 +00:00
Kp 0909b126ac Simplify gr_rle_expand_scanline_generic
Both the `if` and `else` paths had the same loop and post-loop
processing.  The `if` path was a strict subset of the `else` path.  The
`else` path had one setup statement, and was otherwise equal to the `if`
path.  Move the shared statements outside the guarded path.
2017-10-06 01:59:09 +00:00
Kp 8aadb4be5b Use fill_n instead of inline loop to write scanline 2017-10-06 01:59:09 +00:00
Kp 4cfd5f3324 Pass canvas to menubar_init 2017-09-26 04:15:50 +00:00
Kp d7e97ca299 Remove write-only Escort_kill_object
Parallax never implemented Escort_kill_object because it was considered
too much work.  Remove the write-only vestiges of that feature.
2017-09-26 04:15:50 +00:00
Kp bba7e3a153 Move menu_number_bias_wrapper bias into type signature 2017-09-26 04:15:50 +00:00
Lukasz Pawelczyk 9da7ed9e27 Fix build break on OSX
msgbox_error() is defined for both Cocoa and Carbon so the define
should not be used.
2017-09-10 13:27:55 +02: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 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 5073f89dfc Simplify calc_rod_corners loops 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 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 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 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 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 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 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 20a61be716 Flatten serial.h type hierarchy 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 dc33a58225 Use array<> in more places 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
Kp 0645642465 Fix gcc-4.9 pch=1 extern conflict
Using precompiled headers includes vers_id.h into
similar/main/newdemo.cpp.  gcc-4.9 reports a conflict between vers_id.h
`extern const char g_descent_build_datetime[21]` and newdemo.cpp macro
generated `extern const char g_descent_build_datetime[]`.  The size is
only needed in the definition, so remove it from the declaration to
align with the macro-generated extern.
2017-07-08 18:17:48 +00:00
Kp 117d777c3e Shrink serial debuginfo 2017-06-25 20:46:03 +00:00
Kp 103e4a4fb6 Simplify tree_index_sequence 2017-06-25 20:46:03 +00:00
Kp 1e5bf33fc0 Simplify exact_type
exact_type has only one use of its second template parameter.  Move that
use inline to remove it from the type signature.
2017-06-25 20:46:03 +00:00
Kp 9421c31b5a Replace "compiler-type_traits.h" with <type_traits>
Delete stub "compiler-type_traits.h" header.  Redirect all uses to the
standard <type_traits> header.

git grep -wlz 'compiler-type_traits.h' -- '*.cpp' '*.h' | xargs -0 perl -p -i <<EOF
    BEGIN {
	    $i = 0;
    }
    if (($i == 1 && $_ eq "\n") || ($i < 2 && /^#include "/)) {
	    # First blank line or first user-include after a system-include.
	    # Print, then never again for this file.
	    print "#include <type_traits>\n";
	    $i = 2;
    } elsif ($i == 0) {
	    $i = 1 if (/^#include </);
    } elsif ($_ eq "#include \"compiler-type_traits.h\"\n") {
	    # Remove this line if found.
	    $_ = '';
    }
    # Reset state machine when moving to next file.
    $i = 0 if eof;
EOF
2017-06-25 20:46:03 +00:00
Kp adcf02e454 Expand tt:: indirection to std::
All supported compilers have an acceptable <type_traits>.  Commit
4cb3d46148 ("Move <type_traits> test to Cxx11RequiredFeature") made
<type_traits> support mandatory in August and no one has objected.
Remove the indirection and use namespace std directly for type_traits
members.
2017-06-25 20:46:03 +00:00
Kp b550a5aa13 Unify segment2_read
Early unification efforts missed this one because it was in gamemine.c
for Descent 1, but segment.c for Descent 2.  Move it to gamemine.cpp for
both, so that it can be static for both games.
2017-06-17 23:05:16 +00:00
Kp aa47435009 Remove write-only field FuelCenter::MaxCapacity
This is a remnant of a pre-retail design that allowed fuel centers to
be exhausted.  No one has ever asked for this mechanic, so remove
support for it.
2017-06-17 23:05:16 +00:00
Kp 73d92bb509 Make wclip::num_frames uint16_t 2017-06-17 23:05:16 +00:00
Kp c25041fb41 Use array<> for editor Views 2017-06-10 03:31:04 +00:00
Kp 8a038de506 Tighten Marker_viewer_num validation 2017-06-10 03:31:03 +00:00
Kp 7b16571cb2 Rename countarray method count -> size 2017-06-10 03:31:03 +00:00
Kp a03291b036 Rename countarray method size -> max_size 2017-06-10 03:31:03 +00:00
Kp 430f7832aa Move valptridx factories into array_managed_type 2017-06-10 03:31:03 +00:00
Kp 599ac9dee0 Always qualify valptridx type/factory
Previously, valptridx used PREFIX for allow-invalid+mutable, c#PREFIX
for allow-invalid+const, v#PREFIX for require-valid+mutable, vc#PREFIX
for require-valid+const.  Convert the types, factories, and all usage
sites to specify a qualifier for all four combinations:

	im#PREFIX -> allow-invalid+mutable
	ic#PREFIX -> allow-invalid+const
	vm#PREFIX -> require-valid+mutable
	vc#PREFIX -> require-valid+const

Changes to common/include/valptridx.h and common/include/fwd-valptridx.h
are manual.  All other changes are generated by:

	git grep -lz -e '\(obj\|seg\|clwall\|wall\|actdoor\|trg\)\(ptridx\|ptr\|idx\)\(_t\)\?\>' | xargs -0 sed -i -e 's/\<\(v\?\)\(\(obj\|seg\|clwall\|wall\|actdoor\|trg\)\(ptridx\|ptr\|idx\)\(_t\)\?\)\>/\1m\2/g'

for the 'm' prefix and:

	git grep -lz -e '\(obj\|seg\|clwall\|wall\|actdoor\|trg\)\(ptridx\|ptr\|idx\)\(_t\)\?\>' | xargs -0 sed -i -e 's/\<\([cm]\(obj\|seg\|clwall\|wall\|actdoor\|trg\)\(ptridx\|ptr\|idx\)\(_t\)\?\)\>/i&/g'

for the 'i' prefix.
2017-06-10 03:31:02 +00:00
Kp f455d5b8a6 Reorder valptridx macro structure 2017-06-10 03:31:02 +00:00
Kp 79e4e0a628 Raise MAX_POINTS_PER_POLY to 64
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")
2017-06-07 02:44:55 +00:00
Kp b0cb681ae7 Add gcc-7 /*-fallthrough*/ comments for obvious cases
For switch cases where existing comments or code flow logic obviously
intended to fall through, add a gcc-7 /*-fallthrough*/ comment to
silence warnings about this.  Some cases which are less obvious are not
converted, so the code does not yet compile clean with
-Wimplicit-fallthrough.

Reported-by: parkerlreed <https://github.com/dxx-rebirth/dxx-rebirth/issues/338>
2017-06-07 02:44:54 +00:00
Kp c159b831f4 Fix gcc-7 strict-aliasing warning in countarray
Reported-by: parkerlreed <https://github.com/dxx-rebirth/dxx-rebirth/issues/338>
2017-06-07 02:44:54 +00:00
Kp 967edd7ccc Fix make_range for use on non-const lvalue 2017-06-07 02:44:54 +00:00
Kp 32daf8e8c3 Handle unaligned stack during Win32 hexdump logging
The dump logger probes for the end of the stack, then rounds down to the
nearest paragraph boundary to simplify the logic in the hexdump routine.
The termination condition in the hexdump code assumed that there would
exist an integer N such that (`start` + (16 * N) == `end`).  Since `end`
is rounded to a multiple of 16, this held if and only if `start` is also
a multiple of 16.  In practice, this tended to happen, but it was not
guaranteed by the code.  If it ever failed to happen, then the hexdump
routine would not terminate and would instead perform an invalid read
beyond the edge of the stack.

Modify the hexdump routine to round `start` to a multiple of 16 so that
the termination condition works as intended.  This has the useful side
effect that hex dumps now always start paragraph aligned.  When the
stack was not paragraph aligned, this change will cause the hexdump to
show bytes below the stack pointer at the time of the fault.  However,
the stack requirements of the handler itself ensure that these bytes
will be valid.
2017-06-03 17:11:12 +00:00
Kp 806c76ce02 Fix label truncation when strlen(hats) + 1 < strlen(buttons)
Hat labels reserve an extra character for the arrow, which partially
masked this error.  When used buttons requires more characters than (1
+ used hats), the buffer had insufficient space and the label was
truncated.
2017-05-13 04:19:39 +00:00
Kp af55ba08cc Pass grs_canvas &to draw_object_picture 2017-04-30 16:25:16 +00:00
Kp 1a1e669bc6 Pass vms_angvec &to draw_model_picture 2017-04-30 16:25:16 +00:00
Kp 79a4a19711 Pass player to init_player_stats_level 2017-04-30 16:25:16 +00:00
Kp 9478d1e6a5 Add custom terminate handler on Windows 2017-04-22 21:23:56 +00:00
Kp edc3b93c9b Switch valptridx array_size error reporting to %lu
x86_64-w64-mingw32-g++ -Wformat handling misparses the std::size_t
format string, causing a spurious error.

    common/main/valptridx.tcc: In function 'void untyped_index_mismatch_exception::prepare_report(const char*, unsigned int, const void*, long int, const void*, const void*, char (&)[229], std::size_t)':
    common/main/valptridx.tcc:36:182: error: format '%u' expects argument of type 'unsigned int', but argument 7 has type 'std::size_t {aka long long unsigned int}' [-Werror=format=]

This occurs even though the processed text uses %I64u (which is correct
for a `long long unsigned int`), not %u as shown in the error message.

    static void prepare_report(const char *const filename, const unsigned lineno, const void *const array_base, const long supplied_index, const void *const expected_pointer, const void *const actual_pointer, char (&buf)[report_buffer_size], const std::size_t array_size)
    {
	snprintf(buf, sizeof(buf), "%s:%u: " "pointer/index mismatch:" " base=%p size=%" "I64u" " index=%li expected=%p actual=%p", filename, lineno, array_base, array_size, supplied_index, expected_pointer, actual_pointer);
    }

In practice, all such sizes will fit in `unsigned int` because they are
the dimension of an array of large structures.  Switch all platforms to
use `unsigned long`, which works everywhere and is at least as big as
`unsigned int`.  Using `unsigned long` produces the same size as
`std::size_t` on all platforms other than Win64, where `unsigned long`
is only 32 bits due to the strange LLP64 model Microsoft picked.
2017-04-22 21:23:55 +00:00
Kp 2dd4384d9d Move _WIN32_WINNT setup to SConf 2017-04-22 21:23:55 +00:00
Kp 466536b101 Remove abandoned powerup_cap_state
Commit b32298df5a ("Rewrite powerup cap
code to centralize logic") centralized powerup cap code in the
powerup_cap_state class.

Commit 901a554e96 ("New powerup management
code: Addeed functions and packet type to ...") removed all use of
powerup_cap_state, but left the dead implementation present.

Commit 479f5ed584 ("Fix 'format specifies
type 'unsigned short' but the argument has type 'unsigned char''
warning") switched the already dead (but still compiled) code from %hu
to %hhu to fix a warning on OS X.  Although the commit was written by
Chris, it was my suggestion to use %hhu.  I neglected to test Windows
before suggesting it, so the change went in even though Windows does not
accept %hhu; this broke the Windows build.  Fortunately, the code had
been dead for 11 months when the change was made, so the fix for Windows
is to remove the long dead code.
2017-04-22 21:23:55 +00:00
Kp 49cc3aa324 Work around i686-w64-mingw32-g++ compiler crash 2017-04-22 21:23:55 +00:00
Kp 9cfbf44834 Pass object &to toggle_headlight_active 2017-04-22 21:23:55 +00:00
Kp 170d0ac777 Pass canvas &to nm_draw_background 2017-04-08 16:48:20 +00:00
Kp 5d951e4453 Move ogl_sync fence into local scope for before_swap 2017-04-08 16:48:19 +00:00
Kp f70107fb57 Set size of bm_mode to uint8_t 2017-04-08 16:48:17 +00:00
Kp 8184a4609b Simplify gr_rle_decode 2017-04-08 16:48:17 +00:00
Kp 2e1e1b1185 Fix pointer/array::iterator mismatch in scalec.cpp 2017-04-08 16:48:17 +00:00
Kp e7c2bf1957 Fix pointer/array::iterator mismatch in rle.h 2017-04-08 16:48:17 +00:00
Kp b358946924 Show host address/port in timeout message 2017-03-25 19:34:02 +00:00
Kp d5ed019014 Add experimental MP-aware mouselook 2017-03-25 19:34:02 +00:00
Kp 2170c10eed Move MAX_CONTROLCEN_LINKS into control_center_triggers 2017-03-18 18:07:37 +00:00
Kp dd4bdcb770 Inline OGL_TEXTURE_LIST_SIZE 2017-03-18 18:07:37 +00:00
Kp 056115642b Move console.cpp specific constants out of header 2017-03-18 18:07:36 +00:00
Kp 0f57787601 Use enum for console priorities 2017-03-18 18:07:36 +00:00
Kp 297746024b Use enum for GR blending mode 2017-03-18 18:07:36 +00:00
Kp 8d6594effe Inline the sole use of MAX_FLICKERING_LIGHTS 2017-03-18 18:07:36 +00:00
Kp 829e95b6f8 Separate hoard/proximity tracking 2017-03-18 18:07:36 +00:00
Kp 104169dada Move multi_maybe_disable_friendly_fire to dcx 2017-03-18 18:07:36 +00:00
Kp 9878ba2311 Move intro_played to dsx 2017-03-18 18:07:35 +00:00
Kp 85eddb8d02 Pass canvas to render_endlevel_frame 2017-03-11 19:56:28 +00:00
Kp 970ce18410 Pass canvas to render_object 2017-03-11 19:56:27 +00:00
Kp 25c36d4b0e Pass canvas to draw_morph_object 2017-03-11 19:56:27 +00:00
Kp 262d6c6c27 Pass canvas to g3_draw_morphing_model 2017-03-11 19:56:27 +00:00
Kp e1d0d0603f Pass canvas to draw_hostage 2017-03-11 19:56:26 +00:00
Kp f0707cb9bd Pass canvas to draw_powerup 2017-03-11 19:56:26 +00:00
Kp a55de34884 Pass canvas to Laser_render 2017-03-11 19:56:26 +00:00
Kp 753cbafe61 Pass canvas to render_terrain 2017-03-11 19:56:26 +00:00
Kp 113aa50a2a Pass canvas to draw_fireball 2017-03-11 19:56:25 +00:00
Kp 48d9f2cd19 Pass vclip to draw_vclip_object 2017-03-11 19:56:25 +00:00
Kp 450b3ec4f5 Pass canvas to draw_weapon_vclip 2017-03-11 19:56:25 +00:00
Kp 48a6adbe87 Pass canvas to draw_vclip_object 2017-03-11 19:56:25 +00:00
Kp bc11b3bf85 Pass const object to draw_object_tmap_rod 2017-03-11 19:56:25 +00:00
Kp 03043f944e Guard Headlights by if(D2)
Descent 1 has no headlight powerup.  Code to read headlights was
incorrectly added in 357e1b0144, but no code was added to write
headlights, so the Descent 1 lighting code checked for headlights that
never existed.  Guard the headlight global variables and the associated
logic with if(D2).

Fixes: 357e1b0144 ("Made lighting code work with actual RGB values and added feature to let certain objects emit colored dynamic light as well as let mine flash red when control center destroyed (OpenGL-only at the moment)")
2017-03-11 19:56:25 +00:00
Kp a6c8087815 Remove unused compute_object_light parameter rotated_pnt 2017-03-11 19:56:24 +00:00
Kp dfbcc02346 Pass const object to compute_object_light 2017-03-11 19:56:24 +00:00
Kp 84faf8aa73 Pass canvas to draw_object_blob 2017-03-11 19:56:24 +00:00
Kp 4e1156a996 Use canvas in OGL g3_draw_sphere 2017-03-11 19:56:24 +00:00
Kp 9ccddf5366 Pass canvas to draw_exit_model 2017-03-11 19:56:23 +00:00
Kp 719de35484 Pass grs_bitmap to gr_pixel 2017-03-11 19:56:23 +00:00
Kp 9dbec8433d Pass grs_bitmap to gr_upixel 2017-03-11 19:56:23 +00:00
Kp 9311548eba Pass grs_bitmap to ogl_upixelc 2017-03-11 19:56:23 +00:00
Kp c725a6cb88 Pass canvas to gr_init_font 2017-03-11 19:56:22 +00:00
Kp afb52a5a3e Pass canvas to draw_hud 2017-03-11 19:56:22 +00:00
Kp a19286437a Pass canvas to show_mousefs_indicator 2017-03-11 19:56:22 +00:00
Kp 4b6f42a962 Pass canvas to show_reticle 2017-03-11 19:56:22 +00:00
Kp 5e1b27120d Pass canvas to HUD_render_message_frame 2017-03-11 19:56:21 +00:00
Kp d67a27df65 Fix SDL check_header_includes=1 build
Type `SyncGLMethod` was defined conditional on DXX_USE_OGL, but header
`common/include/ogl_sync.h` used `SyncGLMethod` unconditionally.  This
works fine in the normal build since SDL builds never include
`common/include/ogl_sync.h`, but broke the check_header_includes=1 test
since that compiles `common/include/ogl_sync.h` even for SDL builds.

Wrap type `ogl_sync` in `#if DXX_USE_OGL` to hide it from the
check_header_includes=1 test in SDL mode.
2017-03-11 19:56:21 +00:00
Kp f5a17abbe8 Pass canvas to show_HUD_names 2017-03-10 01:22:28 +00:00
Kp 7410ad343c Pass canvas to render_mine 2017-03-10 01:22:28 +00:00
Kp 8542940b24 Pass canvas to render_frame 2017-03-10 01:22:27 +00:00
Kp 393e96b8d8 Unify SDL/OGL save_screen_shot
This simplifies maintenance and reduces the potential for inconsistency.
It also cleans up one existing inconsistency.
2017-03-10 01:22:27 +00:00
Kp c50756c958 Cache canvas in radio.cpp 2017-03-10 01:22:25 +00:00
Kp 5be6b53d16 Fold calls in ui_draw_radio 2017-03-10 01:22:25 +00:00
Kp 0f93dc6e34 Cache canvas in message.cpp 2017-03-10 01:22:25 +00:00
Kp 4d9541d776 Cache canvas in menubar.cpp 2017-03-10 01:22:25 +00:00
Kp a730f68e0b Cache canvas in listbox.cpp 2017-03-10 01:22:25 +00:00
Kp 6ff14b7688 Cache canvas in keypad.cpp 2017-03-10 01:22:25 +00:00
Kp dff67dad1b Cache canvas in inputbox.cpp 2017-03-10 01:22:24 +00:00
Kp 8d5ca033e1 Cache canvas in icon.cpp 2017-03-10 01:22:24 +00:00
Kp 9d4e1e307c Shorten ui_dialog_do_gadgets 2017-03-10 01:22:24 +00:00
Kp 0dc59ab3f2 Simplify ui_dialog_handler switch 2017-03-10 01:22:24 +00:00
Kp 8633b85ee4 Simplify draw_tmap interpolation
Prior changes removed most of what made the switch branches distinct.
Capitalize on that to combine identical code paths.
2017-03-10 01:22:24 +00:00
Kp fe7bb8d36b Use valptridx<wall>::magic_constant for wall_none 2017-03-04 22:25:54 +00:00
Kp a8c3a7f10b Alias Side_to_verts to Side_to_verts_int 2017-03-04 22:25:54 +00:00
Kp cebd2fd36d Pass object &to boss_init_all_segments
The index is not needed.
2017-03-01 02:48:41 +00:00
Kp 482dcf0ba3 Avoid temporarily moving boss while probing layout
Expose sphere_intersects_wall and call it directly from
boss_fits_in_seg, so that boss_fits_in_seg does not need to modify the
position and segment of the boss during the test.
2017-03-01 02:48:40 +00:00
Chris Taylor 19e4c07bb0 Bosses generated by a robot maker or even released by another robot will now teleport
Fixes issue #328.
2017-02-26 10:21:10 +08:00
Chris Taylor 32286ed4fc Play boss looping immediately on loading saved game
If boss has teleported before, even before a loaded state was saved, play the boss looping sound immediately when loading the saved game (if near the boss). Resolves issue #326.
2017-02-26 10:21:10 +08:00
Kp ba914fea81 Pass up various return values 2017-02-26 00:00:02 +00:00
Kp 8a89313ec4 Move compute_segment_center body to dcx 2017-02-22 03:05:44 +00:00
Kp 892d450022 Move compute_center_point_on_side body to dcx 2017-02-22 03:05:43 +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 dc090958d1 Reduce D1 spreadfire cost
Reported-by: zicodxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/322>
Analyzed-by: kreatordxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/322#issuecomment-280896375>
Fixes: 10ff2b9ea2 ("Change Primary_weapon_to_weapon_info key to weapon_id_type")
2017-02-19 19:33:45 +00:00
Kp 6cd6189681 Never pass nullptr to ai_door_is_openable
When objp is nullptr, ai_door_is_openable assumes Buddy_objnum is a
valid object number, but this assumption is not guaranteed to be true.
When it is false, the game crashes.  This crash can be triggered by a
brain robot trying to make nearby robots snipe.

Fix the crash by passing the robot of interest.

Reported-by: Yarn <http://www.dxx-rebirth.com/frm/index.php/topic,2165.0.html>
2017-02-19 19:33:45 +00:00
Kp 859b399d20 Use mask for Secondary_last_was_super 2017-02-19 19:33:45 +00:00
Kp 7c658fd8cd Use mask for Primary_last_was_super 2017-02-19 19:33:44 +00:00
Kp a6cd87613c Pass polymodel &to free_model 2017-02-19 19:33:44 +00:00
Kp 1a7659897a Pass canvas to draw_model_picture 2017-02-19 19:33:44 +00:00
Kp 39071d124d Pass canvas to draw_polygon_model 2017-02-19 19:33:43 +00:00
Kp b918760b3f Move find_connect_side body to dcx 2017-02-19 19:33:38 +00:00
Kp b82d9d2b51 Move get_side_verts body to dcx 2017-02-19 19:33:38 +00:00
Kp 9821a77372 Simplify use of get_num_faces 2017-02-19 19:33:38 +00:00
Kp cdb193c053 Use unsigned for sides/verts in more places 2017-02-19 19:33:38 +00:00
Kp 0f00cf51b0 Make segment vertices unsigned 2017-02-19 19:33:37 +00:00
Kp ef928d39c0 Fix check_header_includes=1 gamemine.h 2017-02-19 19:33:37 +00:00
Kp 45d7c6da65 Fix check_header_includes=1 wall.h 2017-02-19 19:33:36 +00:00
Kp a815541ef5 Fix check_header_includes=1 poison.h 2017-02-19 19:33:36 +00:00