Commit graph

3145 commits

Author SHA1 Message Date
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
Kp cd25b55305 Fix check_header_includes=1 fwd-valptridx.h 2017-02-19 19:33:36 +00:00
Kp 569d64e927 Propagate Hack_DblClick_MenuMode 2017-02-11 21:42:47 +00:00
Kp 97cf921b72 Cache canvas in ui_draw_checkbox 2017-02-11 21:42:46 +00:00
Kp 2725ea02c2 Cache canvas in ui_draw_button 2017-02-11 21:42:46 +00:00
Kp fb53bc9257 Pass canvas to player_dead_message 2017-02-11 21:42:46 +00:00
Kp 05905ced06 Pass font to gr_get_string_wrap 2017-02-11 21:42:44 +00:00
Kp 69a4857ba5 Pass canvas to ui_draw_box_in1 2017-02-11 21:42:44 +00:00
Kp 75ffb6b778 Add valptridx trap for dereferencing a null pointer 2017-02-11 21:42:44 +00:00
Kp dfe827e793 Relax valptridx<T>::guarded compile-time checks
When using `gcc -fsanitize=undefined`, the compiler proves trivial
results, so `DXX_CONSTANT_TRUE` is defined.  It then fails to prove that
`DXX_CONSTANT_TRUE(m_state == checked)` is false, causing a compile-time
error.  Relax the check to occur only when it can prove `m_state` equal
to a disallowed value, rather than when it cannot prove `m_state` equal
to an allowed value.

Move the preprocessor guard so that the runtime check is always visible.
Optimizing compilers can still eliminate that check at compile-time when
it provably never fails.
2017-02-11 21:42:43 +00:00
Kp 17208cca79 Disallow int for vm_distance_squared 2017-02-11 21:42:43 +00:00
Kp d8638c6c89 Pass canvas to UP_ARROW_MARKER, DOWN_ARROW_MARKER 2017-02-11 21:42:43 +00:00
Kp 6b8f08142f Pass canvas to LINE_SPACING
Macro LINE_SPACING previously used global grd_curcanv implicitly.
Change it to take a canvas argument.  Change all callers to pass
grd_curcanv, so that usage is explicit.
2017-02-11 21:42:42 +00:00
Kp ed9fe62d85 Expand GHEIGHT
As a macro, it always refers to the global grd_curcanv.  This interferes
with converting canvas handling to be an argument.  Expand GHEIGHT so
that uses of grd_curcanv can be changed individually.
2017-02-11 21:42:42 +00:00
Kp 03c43b1d7f Expand GWIDTH
As a macro, it always refers to the global grd_curcanv.  This interferes
with converting canvas handling to be an argument.  Expand GWIDTH so
that uses of grd_curcanv can be changed individually.
2017-02-11 21:42:42 +00:00
Kp 0d5d2e77a8 Pass canvas to g3_check_and_draw_poly 2017-02-11 21:42:42 +00:00
Kp 48bf96fe6a Pass canvas to g3_draw_bitmap 2017-02-11 21:42:42 +00:00
Kp 761c926604 Pass canvas to g3_draw_tmap_2 2017-02-11 21:42:41 +00:00
Kp f279bb8497 Pass canvas to _g3_draw_tmap_2 2017-02-11 21:42:41 +00:00
Kp c732c35916 Pass canvas to g3_draw_poly 2017-02-11 21:42:41 +00:00
Kp 66ee668e48 Pass canvas to _g3_draw_poly 2017-02-11 21:42:41 +00:00
Kp 214d930e14 Pass canvas to must_clip_flat_face 2017-02-11 21:42:41 +00:00
Kp 416954bbdf Pass canvas to gr_upoly_tmap 2017-02-11 21:42:40 +00:00
Kp 85da2c0013 Pass canvas to g3_draw_polygon_model 2017-02-11 21:42:40 +00:00
Kp b7bbe21e4d Add const to interpreter model_bitmaps 2017-02-11 21:42:40 +00:00
Kp 59b57bd7dc Pass canvas to g3_check_and_draw_tmap 2017-02-11 21:42:40 +00:00
Kp cd8f408269 Pass canvas to draw_object_tmap_rod 2017-02-11 21:42:40 +00:00
Kp 394d9e1b80 Pass canvas to g3_draw_rod_tmap 2017-02-11 21:42:40 +00:00
Kp 6a2f3c1321 Pass canvas to g3_draw_tmap 2017-02-11 21:42:39 +00:00
Kp 4791a40007 Pass canvas to _g3_draw_tmap 2017-02-11 21:42:39 +00:00
Kp a0538843b7 Pass canvas to must_clip_tmap_face 2017-02-11 21:42:39 +00:00
Kp 19151c12d9 Pass canvas to draw_tmap{,_flat} 2017-02-11 21:42:39 +00:00
Kp 2a403f74a0 Pass canvas to gr_upoly_tmap_ylr 2017-02-11 21:42:39 +00:00
Kp 742c463858 Pass canvas to texture_map_flat 2017-02-11 21:42:39 +00:00
Kp e288c20014 Pass canvas to tmap_scanline_flat 2017-02-11 21:42:39 +00:00
Kp bc91e8b789 Propagate function pointer into texture_map_flat 2017-02-11 21:42:38 +00:00
Kp 6f81d13c41 Pass canvas to gr_set_curfont 2017-02-11 21:42:38 +00:00
Kp d4aa43c17e Cache canvas in ui_draw_scrollbar 2017-02-11 21:42:37 +00:00
Kp 7a6818eb01 Fold ui_draw_checkbox calls 2017-02-11 21:42:36 +00:00
Kp 842bd7a649 Pass canvas to ui_string_centered 2017-02-11 21:42:36 +00:00
Kp aa9b9a8346 Pass canvas to ui_draw_box_in 2017-02-11 21:42:36 +00:00
Kp 04c7f7c790 Pass canvas to ui_draw_box_out 2017-02-11 21:42:35 +00:00
Kp a51b071053 Pass canvas to ui_draw_frame 2017-02-11 21:42:35 +00:00
Kp 5636a85f3c Pass canvas to ui_draw_shad 2017-02-11 21:42:35 +00:00
Kp cf1f5df3cc Pass canvas to Vline 2017-02-11 21:42:35 +00:00
Kp f9cb598b0f Pass canvas to Hline 2017-02-11 21:42:35 +00:00
Kp 13320c8011 Fold ui_draw_button calls to gr_rect 2017-02-11 21:42:34 +00:00
Kp e765f8b744 Reorder ui_draw_button to support folding 2017-02-11 21:42:34 +00:00
Kp f28a5e77f1 Fold ui_draw_button calls to gr_set_fontcolor 2017-02-11 21:42:34 +00:00
Kp 554daa61cc Pass font to ui_get_button_size 2017-02-11 21:42:34 +00:00
Kp 1413264697 Cache canvas in print_clock 2017-02-11 21:42:34 +00:00
Kp beaa49a7ba Pass destination bitmap to scale_bitmap 2017-02-11 21:42:34 +00:00
Kp 590a025a89 Pass canvas to g3_start_frame 2017-02-11 21:42:34 +00:00
Kp 740b3a9649 Pass canvas to ogl_start_frame 2017-02-11 21:42:33 +00:00
Kp 80e7ade6a1 Pass canvas to g3_draw_sphere 2017-02-11 21:42:33 +00:00
Kp 513e7ceceb Pass canvas to g3_draw_line 2017-02-11 21:42:33 +00:00
Kp b7d266897c Pass canvas to must_clip_line 2017-02-11 21:42:33 +00:00
Kp 47a319bba5 Pass canvas to g3_draw_line 2017-02-11 21:42:33 +00:00
Kp d779a26307 Pass canvas to gr_bm_ubitblt0x_rle 2017-02-11 21:42:33 +00:00
Kp f8b057d43d Pass canvas to gr_bm_ubitbltm 2017-02-11 21:42:32 +00:00
Kp 9cc5d6f439 Pass canvas to gr_bm_ubitblt 2017-02-11 21:42:32 +00:00
Kp ae33aaafc1 Pass canvas to gr_set_fontcolor 2017-02-11 21:42:32 +00:00
Kp 0dcae721d9 Make canvas an explicit argument to gr_printf
Previously, a macro implied *grd_curcanv as the canvas.  Pass the canvas
explicitly so that callers can choose the canvas to use.
2017-02-11 21:42:32 +00:00
Kp d1657ba269 Make canvas an explicit argument to gr_uprintf
Previously, a macro implied *grd_curcanv as the canvas.  Pass the canvas
explicitly so that callers can choose the canvas to use.
2017-02-11 21:42:32 +00:00
Kp 227eb98c3e Pass player_info to do_cockpit_window_view 2017-02-11 21:42:31 +00:00
Kp 8783c22003 Remove obsolete ogl_pal 2017-02-11 21:42:31 +00:00
Kp 2cf0a0034a Simplify g3_draw_poly call stack 2017-02-11 21:42:31 +00:00
Kp 1a3d89aecf Use vsegptridx in editor group functions 2017-02-11 21:42:31 +00:00
Kp 43a700a200 Prefer grs_main_bitmap::reset() to direct reinitialization
This ensures that any allocated resources are always freed.
2017-02-11 21:42:31 +00:00
Kp c242319829 Use RLE helper for bitblt RLE decoding 2017-02-11 21:42:30 +00:00
Kp c1440ff995 Factor out RLE expansion
Many sites open-coded walking a bitmap and handling whether it was
RLE_BIG.  Factor that out into a helper class and redirect those sites
to use it.
2017-02-11 21:42:30 +00:00
Kp 7df99350dd Pass player to do_laser_firing_player 2017-02-08 23:34:41 +00:00
Kp 82d10b910c Pass player_info to allowed_to_fire_laser 2017-02-08 23:34:41 +00:00
Kp c16b7763e9 Remove unused ui_draw_line_in 2017-02-08 23:34:41 +00:00
Kp d40c636ecc Reorder gr_free_bitmap_data to improve tail call optimization 2017-02-08 23:34:41 +00:00
Kp 98c9374a12 Simplify powerup_grab_cheat_all path
Movement handling has an ugly hack that tries to grab powerups near the
console player, but it reuses general collision handling and fails to
check whether the player is alive.

Add a liveness check.  Place the check so that it happens once, before
the objects are scanned, rather than being needlessly repeated for every
object.

Refactor the collision code to let the movement hack skip the parts it
does not need.

Reported-by: ryusei117 <https://github.com/dxx-rebirth/dxx-rebirth/issues/302#issuecomment-275816259>
2017-02-04 23:10:29 +00:00
Kp 6ac840c52c Fix pch=1 build
PCH mode causes the Valgrind-wrapper header to be included in places
it is not meant to be used, which leads to spurious compiler errors.

PCH mode causes the Valgrind-wrapper __real_* stub functions to see
the physfsx.h PHYSFS macros, which also causes errors.

Fortunately, both cases can be easily fixed.

Add preprocessor guards to the Valgrind-wrapper header to cause it to
compile out when the PCH phase runs.  It has no include guard, so it
will be rescanned with the proper macros when the two consuming files
are built normally.

Modify the Valgrind-wrapper __real_* stub functions to use
the standard macro avoidance trick so that they do not call the
physfsx.h PHYSFS macros.
2017-01-31 04:25:06 +00:00
Kp 59bad96d5f Add back homing weapons cheat for D2
Kreator proposed restoring the Descent 2 cheat that grants homing
capability to all weapons.  This commit implements that proposition,
with some changes to the implementation details.

Based-on-patch-by: Chris Taylor <chris@icculus.org>
Requested-by: Chris Taylor <https://github.com/dxx-rebirth/dxx-rebirth/pull/318>
2017-01-29 21:02:48 +00:00
Chris Taylor 2f4db4a048 Player keeps any keys collected on a secret level even if they die on the secret level 2017-01-29 07:54:43 +08:00
Kp 8c706a88bd Initialize grs_main_bitmap at construction 2017-01-28 18:12:20 +00:00
Kp fc12995d89 Add options for reduced-size valptridx error reporting 2017-01-28 18:12:20 +00:00
Kp c46a0ce27c Remove some remotely-triggerable fatal exceptions
By design, valptridx will throw an exception on invalid input.  This is
better than silently permitting invalid input to corrupt program state.
Past releases blindly trusted that multiplayer peers would not send
invalid input.  Conversion to the valptridx design eliminated the
undefined behavior when peers send invalid input, but still allowed
multiplayer peers to remotely crash the game by sending invalid inputs.
Add a mechanism to trap invalid inputs and gracefully ignore those
messages.  This may cause game consistency issues, but will not allow
data corruption.
2017-01-28 18:12:20 +00:00
Chris Taylor 30b5ef7c73 Create robot_create function and use it 4x
Contains 2 calls - to obj_create and init_ai_object. For safety reasons and tidiness compared to using obj_create directly. The call to init_ai_object in recreate_thief was already redundant.
2017-01-22 17:56:50 +08:00
Kp baa187801b Add special case to make past releases not die on various segnums
All releases to date have a bug where they treat certain segment number
fields as an int, not a segment number.  Storing segment_none (0xffff)
into the save file causes affected releases to crash in various places
because it fails to recognize that this is segment_none.

Current code correctly treats segment_none as a non-segment and works
correctly without this hack.  The hack is only required to get past
releases to work correctly after loading a saved game written by current
code.
2017-01-21 19:05:43 +00:00
Kp fd2c8df74e Raise MAX_WALLS to 255
Raise D2 MAX_WALLS to 255, since Walls[254] is not special.  Synchronize
D1 MAX_WALLS to D2 MAX_WALLS to fix D1 Level of the World BRDECON.

Requested-by: Ryusei117 <http://www.dxx-rebirth.com/frm/index.php/topic,1760.msg22509.html#msg22509>
2017-01-18 03:06:02 +00:00
zico b644ab575c Raised MAX_DELTA_LIGHTS to 32000. 2017-01-15 14:12:03 +01:00
zico 5acbb949de Raised MAX_NUM_FUELCENS and MAX_ROBOT_CENTERS to 128. 2017-01-15 13:43:02 +01:00
Kp 092d947830 Optimize change_light search
Use std::equal_range to find the upper and lower bounds in a single
binary search, rather than relying on a linear search to find the first
sought element.
2017-01-15 00:03:14 +00:00
Kp 3594e7093f Switch last_hitobj to use array<objnum_t> instead of bitset
This reduces the number of objects that can be tracked concurrently, but
allows MAX_OBJECTS to rise without causing `laser_info` to grow.
2017-01-15 00:03:13 +00:00
Kp 6d3fb34268 Abstract out last_hitobj management 2017-01-15 00:03:13 +00:00
Kp d908b22fdc Move weapon_id_type to namespace dsx 2017-01-15 00:03:13 +00:00
Kp 764d20d4e1 Make grs_bitmap::bm_flags private 2017-01-15 00:03:13 +00:00
Kp 96cc5a40b8 Remove dead preprocessor guards
Some bitblt code had guards of the form:

	#if A
	xxx
	#if !A
	yyy
	#endif
	zzz
	#endif

If A is true, !A is false, so the inner block can never be included.
Delete it.
2017-01-15 00:03:12 +00:00
Kp f4fffeea49 Make more render state const when possible
Make Render_zoom const in builds where there are no statements that can
change it.

Use vcseg, not vseg, for some segment accesses.
2017-01-15 00:03:12 +00:00
Chris Taylor bde055a6a1 Fix 'declaration shadows a field of 'dcx::ogl_sync'' warning
Replace fence with fence_func in implementation of ogl_sync::sync_deleter::operator().
2017-01-13 12:30:09 +08:00
Chris Taylor 0c5a000328 Remove call to window_close(Game_wind) when a network event tells us to end the game
In multi_do_frame(), replace call to window_close(Game_wind) with returning window_event_result::close whenever multi_quit_game is true. Only using this return value where multi_do_frame() is directly called by GameProcessFrame(). multi_quit_game will only be set back to 0 when a new multi game is started.

Closing a window within its handler is problematic - it can result in an unstable state.
2017-01-10 14:10:39 +08:00
Chris Taylor a418f8caec Remove call to window_close(Game_wind) when multiplayer level syncing fails
Replace call to window_close(Game_wind) with returning window_event_result::close to game_handler. Applies to when there is a failure in net_udp_level_sync(). Closing a window within its handler is problematic - it can result in an unstable state.
2017-01-10 13:02:59 +08:00
Chris Taylor 2ecc4c4a07 Remove call to window_close(Game_wind) when stopping demo playback
Replace call to window_close(Game_wind) with returning window_event_result::close to game_handler. Applies to whenever newdemo_stop_playback() is called. Closing a window within its handler is problematic - it can result in an unstable state.
2017-01-09 19:09:34 +08:00
kreatordxx f590ec45c6 Merge pull request #298 from dxx-rebirth/no_game_wind_close
Remove calls to window_close(Game_wind)
2017-01-09 09:32:24 +08:00
Kp 7fafc22cca Poison multiplayer object_rw without making it unreadable
`struct object_rw` is poisoned prior to initializing and sending it.
However, some fields are legitimately unininitialized (other than their
memset or poison value) at send time.  Add and use a poison variant that
can clear those fields, without marking them unreadable.
2017-01-08 22:32:00 +00:00
Kp 5da784dbed Pass canvas to gr_{,u}string 2017-01-08 22:32:00 +00:00