Commit graph

4732 commits

Author SHA1 Message Date
Kp 04cfd817c3 Cache scores variables 2021-09-19 10:53:48 +00:00
Kp e618851449 Pass canvas to savegame_chooser_newmenu 2021-09-19 10:53:48 +00:00
Kp 70169c4921 Compute briefing window dimensions from caller's canvas 2021-09-19 10:53:48 +00:00
Kp dfc51fd822 Remove newmenu updates of grd_curcanv
They are no longer needed.
2021-09-19 10:53:48 +00:00
Kp aba5fce3a9 Use enum class for gr fade_level 2021-09-19 10:53:48 +00:00
Kp 0216cdc68d Derive title screen dimensions from canvas 2021-09-19 10:53:48 +00:00
Kp 07c52f14f9 Save parent canvas in listbox_layout 2021-09-12 16:20:52 +00:00
Kp bef23a3894 Use newmenu's parent canvas in newmenu_draw
Avoid resetting to screen canvas.
2021-09-12 16:20:52 +00:00
Kp 8d67bcddb0 Record parent canvas in newmenu
Use it to avoid resetting to the screen canvas when preparing the
layout.
2021-09-12 16:20:52 +00:00
Kp bb29e6fca8 Propagate canvas through more layers 2021-09-12 16:20:52 +00:00
Kp 8623ce3c6a Pass canvas to ogl_draw_vertex_reticle 2021-09-12 16:20:52 +00:00
Kp 3c37552e5b Use enum class bm_mode for grs_bitmap::type 2021-09-12 16:20:52 +00:00
Kp e7aa9855e0 Compute menu border widths from screen canvas instead of screen
In practice, this should be the same result.  However, this allows the
flexibility to use a canvas other than the screen.
2021-09-12 16:20:52 +00:00
Kp 21241471c6 Return string width/height from gr_get_string_size
Use structured bindings to capture the values on return, so that they
can be declared as `const` if they are immutable after initial
computation.
2021-09-12 16:20:52 +00:00
Kp 0750046bc1 Move retrieval of font average width out of gr_get_string_size
Most callers do not need it, and it is only vaguely related to the
purpose of measuring a particular string.  For those callers that need
it, lift it out.
2021-09-12 16:20:52 +00:00
Kp 2fef4cddec Pass canvas to do_cockpit_window_view 2021-09-12 16:20:52 +00:00
Kp 3aa1140700 Optimize out warn_printf on some targets
Some targets only ever use GUI warn functions.  On those targets:
- initialize `warn_func` to `msgbox_warning` at compile time
- remove the runtime initialize of warn_func in main

On targets which do not call `clear_warn_func`, preprocess out its
declaration and definition.

Taken together, these changes allow some targets not to define
`warn_printf`.
2021-09-12 16:20:52 +00:00
Kp 2f4f0299a0 Fix Windows build of dumpmine.cpp
On x86_64-w64-mingw32, `uint_fast32_t` is `unsigned int`.  Use the
appropriate format macro for it, instead of writing `lu` and expecting
that `uint_fast32_t` will be `unsigned long`.
2021-09-12 16:20:52 +00:00
Kp bd6612a86b Pass canvas to render_gauges 2021-09-12 16:20:52 +00:00
Kp 4b60205b2f Propagate up show_boxed_message RenderFlag
It is always constant.  Explicitly propagate its effects into callers,
then remove the argument.
2021-09-12 16:20:52 +00:00
Kp 2da07e75e5 Fix gcc-7 editor build
gcc-7 warns if a structured binding defines a variable, and then does
not use it.  Suppress the warning, since the binding is needed in the
non-editor build.
2021-09-12 16:20:52 +00:00
Kp df6777c632 Expand game_init_render_buffers inline
It is a single function, to add 2 arguments.  Using a wrapper obfuscates
the logic.
2021-09-12 16:20:52 +00:00
Kp 4d3c38084d Factor out VR stereo subcanvas initialization 2021-09-12 16:20:52 +00:00
Kp 98f2578293 Pass Game_mode as a parameter to gauges functions
Avoid reloading it from the global.
2021-09-12 16:20:52 +00:00
Kp 2b718da343 Use enum class for Game_mode, Newdemo_game_mode 2021-09-12 16:20:52 +00:00
Kp 48a3ac2c53 Lift ogl_start_frame eye handling into caller 2021-09-12 16:20:52 +00:00
Kp 7f51fa3ac5 Use enum class for VR StereoFormat 2021-09-12 16:20:52 +00:00
Kp 007ac68569 Reduce size of pause_window::msg
1024 is excessive.  128 leaves 25 bytes unused on Trainee (the longest
difficulty string, tied with Hotshot) at time 0:00:00.  A player who
reached double-digit hours for both time on level and time in game would
need 2 bytes more.  A player who rescued 100 hostages would need another
2 bytes.
2021-09-12 16:20:52 +00:00
Kp 233f31893b Only prepare pause time if it will be shown
Demo playback does not show time data, so there is no need to format it
when it will be hidden.
2021-09-12 16:20:52 +00:00
Kp 211f4ea274 Use window_rendered_data constructor to initialize time 2021-09-12 16:20:52 +00:00
Kp 2afe2f428f Remove write-only member window_rendered_data::viewer 2021-09-12 16:20:52 +00:00
Kp fdf5836031 Move g3 instance contexts onto the stack 2021-09-04 12:17:14 +00:00
Kp c99b67e359 Switch callers to unchecked_partial_range(range) where possible
Use unchecked_partial_range(range) instead of
unchecked_partial_range(iterator), since the range form can preserve the
underlying index_type.
2021-09-04 12:17:14 +00:00
Kp ef1c3d20c6 Compute required_buffer_size earlier in partial_range call tree
Push the computation up, so that invocations that differ only in the
length of their expression strings will resolve to the same template.

Rework unchecked_partial_range not to take expression strings if they
will not be used.
2021-09-04 12:17:14 +00:00
Kp 21f736ec37 Require grs_subcanvas for gr_init_sub_canvas
Prevent passing a canvas that is not specifically typed as a
grs_subcanvas.
2021-09-04 12:17:14 +00:00
Kp 8eabce8f27 Disallow direct construction of grs_canvas
Require use of grs_main_canvas or grs_subcanvas instead.
2021-09-04 12:17:14 +00:00
Kp 3cf612fe53 Simplify say_unused_tmaps
Reduce the number of physfs calls.  Use zip+range-for to iterate all the
sequences at once.
2021-09-04 12:17:14 +00:00
Kp 983ad86e4b Use enum class for trigger number 2021-09-04 12:17:14 +00:00
Kp 6ab3fb262b Add convenience function underlying_value
Add a helper to deduce the enum type of a value, and use an appropriate
std::underlying_type<T> expression for that enum type.  This avoids the
need to repeat the type of the enum at the site of each cast, and moves
the casts into the helper to make the callers easier to read.
2021-09-04 12:17:14 +00:00
Kp c58d26a791 Use trgnum_t more consistently 2021-09-04 12:17:14 +00:00
Kp 6dcd89d494 Try harder to pick distant segments for thief/powerup respawn 2021-09-04 12:17:14 +00:00
Kp 810be506a3 Inline AI path shuffle
- Use std::iota to initialize the translation array
- Switch from conditionally using either a linear count or the array to
  always using the array.  In non-random mode, the array is initialized
  and never shuffled, so it should produce the same effect as using the
  linear count, but avoids a branch in the loop.
- Switch to using std::shuffle driven by std::minstd_rand, rather than
  an inline swap loop using d_rand() to pick indices.
- Reorder the shuffle logic to have exactly one invocation in each game,
  so that the shuffle call itself can be eligible for inlining.
- Use std::uniform_int_distribution to decide whether to reshuffle in
  Descent 2.  Maintain the original logic that reshuffling happens 25%
  of the time.
2021-09-04 12:17:14 +00:00
Kp 9dca02a723 Report libpng version information in -verbose startup output 2021-08-31 02:20:06 +00:00
Kp 2c3a258d17 Fix bogus clang -Wunused-variable warning 2021-08-26 03:13:46 +00:00
Kp 2a5562e671 Fix clang -Wformat warning in segment selection dialog
clang warns because %hu was used to format a value that is `unsigned`.
Change the format accordingly.
2021-08-26 03:13:46 +00:00
Kp 2b29f91edc Convert various PHYSFSX_printf to PHYSFSX_puts_literal
clang-12 warns when the format string checking logic indexes off the end
of a very short format string to PHYSFSX_printf.  In each case, the call
had no variadic arguments, so it can be switched to PHYSFSX_puts_literal
to make the code simpler and eliminate the warning.
2021-08-26 03:13:46 +00:00
Kp fb63a73bd1 Filter out robots at render time, not wakeup time
A robot that is rendered may be woken later, subject to some conditions.
Move the easily checked conditions into the renderer, so that robots
which will not be woken are never recorded.
2021-08-26 03:13:45 +00:00
Kp 40c22d0663 Move render_frame helper inline
Most call sites had the correct lifetime already, and those that did not
can easily gain it with an extra block scope.
2021-08-26 03:13:45 +00:00
Kp 4b062bd7b2 Reorder check_effect_blowup tests to reduce D2 redundancy
Switch from ((a && b) || (!a && c)) to (!a ? c : b).
2021-08-26 03:13:45 +00:00
Kp e0820e2825 Skip autosave while in demo playback modes
Reported-by: polstomo <https://github.com/dxx-rebirth/dxx-rebirth/issues/598>
2021-07-25 23:00:56 +00:00