Commit graph

3838 commits

Author SHA1 Message Date
Kp 8eafbe6197 Shrink window::w_modal to uint8_t 2021-11-01 03:37:18 +00:00
Kp 3cca690728 Assign weakly-typed symbolic names to ogl_ubitmapm_cs special cases 2021-11-01 03:37:18 +00:00
Kp 961aae074a Remove unused ogl_ubitmapm_cs argument scale
Every caller passes `F1_0`.  Remove the argument, and propagate its
results through the function.
2021-11-01 03:37:18 +00:00
Kp 1a08ecc8c6 Remove window subfunction types
These were type safety mechanisms, which are obsolete now that all
window handlers are implemented through virtual function dispatch.
2021-10-13 02:37:51 +00:00
Kp 192988b004 Use enum class for weapon_info::persistent 2021-09-19 10:53:48 +00:00
Kp 21c530a3e2 Use enumerated_array for difficulty-level-specific arrays 2021-09-19 10:53:48 +00:00
Kp 7fc8c736b3 Pass Powerup_info to multi_prep_level_objects, filter_objects_from_level 2021-09-19 10:53:48 +00:00
Kp 4e75f8a933 Pass canvas to scores_view_menu 2021-09-19 10:53:48 +00:00
Kp 855697bf5d Make font scaling constructors explicit 2021-09-19 10:53:48 +00:00
Kp b05905ab4d Delegate score comma handling to std::locale 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 aba5fce3a9 Use enum class for gr fade_level 2021-09-19 10:53:48 +00:00
Kp 5caa4755b1 Shrink gr_blend to uint8_t
Larger values are not needed.
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 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 5881af50dd Use __builtin_FILE,LINE for canvas location debugging
This avoids declaring macros for gr_set_default_canvas,
gr_set_current_canvas.
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 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 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 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 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 6172b69329 Convert more font.cpp sites to use xrange 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 b6bebcf6b8 Propagate T::index_type through partial_range
When partial_range is used on a container that defines index_type,
define that same index_type on the partial_range.  This allows other
callers, such as enumerate(), to maintain the correct index type.
2021-09-04 12:17:14 +00:00
Kp 16aa554c0e Remove anonymous namespace in partial_range
All the affected symbols are templates, so duplicate instantiations will
not cause duplicate definition errors.  Removing the anonymous namespace
wrapper will allow equivalent definitions from different source files to
be folded together, reducing the size of the executable.
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 45d72183ce Rename type/var for partial_range begin/end
- UO -> index_begin_type
- o -> index_begin
- UL -> index_end_type
- l -> index_end
- I -> range_exception

The original names were picked because `l` was the length of the
subrange.  Rename these to more closely follow STL's begin/end
nomenclature.

`I` was used variously for an iterator type and for the exception type
thrown on error.  Rename the latter to be descriptive.
2021-09-04 12:17:14 +00:00
Kp 23f03d0a5e Add unit tests for partial_range 2021-09-04 12:17:14 +00:00
Kp ae3dc7f934 Simplify computed color reset
gr_find_closest_color did not need it.  Remove it.  For the others,
resetting the count is sufficient.  There is no need to reset the
individual elements.
2021-09-04 12:17:14 +00:00
Kp fb3c2a4808 Narrow grs_canvas fg/bg color fields 2021-09-04 12:17:14 +00:00
Kp 2c2ef3fa33 Factor out common logic in rle conditionals 2021-09-04 12:17:14 +00:00
Kp 3697aabcdd RLE processing: use varying pointer types instead of multiplication 2021-09-04 12:17:14 +00:00
Kp 5bd093b3cb Rework gr_rle_getsize
- Add a limiter to let it return early when the result is predictable.
  The first caller checks only whether the returned value is above a
  threshold.  Once the value goes above that threshold, its precise
  value will not matter, so stop counting and return early.
- Add comments explaining some of the logic.
2021-09-04 12:17:14 +00:00
Kp 15f944b0b6 Skip trying to rle compress a paged-out bitmap
This would crash if it ever happened, so skip such bitmaps.
2021-09-04 12:17:14 +00:00
Kp 99e14b4100 Factor out common paths in gr_rle_encode 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 1c90863d63 Move grs_main_bitmap earlier in the header 2021-09-04 12:17:14 +00:00
Kp 44a50b6206 Make enumerate() index by array's index_type 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 7c09ca75c5 Fix valptridx build for gcc-7
In gcc-7, expressions on the false path of `if constexpr` are deleted
before they are considered "used", so a variable that is only used on a
deleted path is reported as an unused variable.  Add an alternate path
that casts the variable to void so that it is always used.
2021-08-31 02:20:06 +00:00
Kp 514a146102 Update tool_bundle.py membership test for SCons 4.2.0
SConstruct 4.2.0 removes `Environment.has_key`[1].  Switch to use
`__contains__`, which works in SConstruct 4.1.0 and SConstruct 4.2.0.

[1]: https://scons.org/scons-420-is-available.html :
```
Internal has_key methods removed from SCons' dictionary-like objects SubstitutionEnvironment and OverrideEnvironment - in other words, an env - to match Python 3 which no longer has dict.has_key.
```

Reported-by: nastys <https://github.com/dxx-rebirth/dxx-rebirth/issues/561#issuecomment-907872094>
Reported-by: Kreeblah <https://github.com/dxx-rebirth/dxx-rebirth/issues/561#issuecomment-907876676>
2021-08-31 02:20:06 +00:00
Kp 828cadd54f Use constexpr if in valptridx tests for allow_nullptr 2021-08-26 03:13:46 +00:00
Kp 5d39c52b0c Remote write-only field UI_GADGET::status 2021-08-26 03:13:46 +00:00
Kp be5061c072 Remove write-only field UI_GADGET::oldstatus 2021-08-26 03:13:46 +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 079ab168a4 Move View_zoom out of global scope
It is only used briefly, so it can be local.
2021-08-26 03:13:45 +00:00
Kp 3b5134896f Remove unused return value of gr_bitmap_rle_compress 2021-08-26 03:13:45 +00:00
Kp 506ab6e5de Make prohibit_void_ptr methods constexpr 2021-08-26 03:13:45 +00:00
Kp d748e7bbfc Add support for xrange steps other than +1
Prior to this, an xrange always started at the begin term and
incremented by 1 per step until it reached the end term.  There was no
support for a step size other than 1.  Add support for custom step size.
It is the caller's responsibility to pick a step size that will
eventually lead to (iter != end) evaluating to false.
2021-08-26 03:13:45 +00:00
Kp 56c98f5345 Improve error reporting for PHYSFSX_openWriteBuffered
Return the PHYSFS error code on failure, so that callers can report why
the open failed.
2021-07-25 23:00:56 +00:00
Kp 1c13d3c8d3 Improve error reporting for PHYSFSX_openReadBuffered
Return the PHYSFS error code on failure, so that callers can report why
the open failed.
2021-07-25 23:00:56 +00:00
Kp b2968c55da Improve error reporting for read_sndfile
Move error reporting down into read_sndfile, so that individual failure
paths can have specific error messages.
2021-07-25 23:00:56 +00:00
Kp a7cbf60922 Return error code from PHYSFSRWOPS_openRead*
This improves error reporting for movies.
2021-07-25 23:00:56 +00:00
Kp b814301120 Pass PhysFS error code to callers of PHYSFSX_addRelToSearchPath
Use PHYSFS_getLastErrorCode on the result.  This allows init_movie to
report the reason a movie was unavailable.
2021-07-25 23:00:56 +00:00
Kp 1227625e7c Remove unused return code of PHYSFSX_removeRelFromSearchPath 2021-07-25 23:00:56 +00:00
Kp e0008cceb3 Use enum class for sound angle parameter 2021-06-28 03:37:51 +00:00
Kp 13e29c64f3 In debug builds, initialize newmenu_item type,text to poison values
This improves the chance that an unset value will abort rather than
displaying strange results.  Release builds are unchanged.
2021-06-28 03:37:51 +00:00
Kp ec4d75d44e Switch decode_row from xrange to span to better express its operation 2021-06-28 03:37:51 +00:00
Kp 9c08b233a5 Move collision functions into namespaces 2021-06-28 03:37:51 +00:00
Kp e1aac6949a Replace __attribute_warn_unused_result with C++17 [[nodiscard]]
This eliminates a configure test, and may help readers understand the
annotation more readily.
2021-06-28 03:37:51 +00:00
Kp 770ae0cea5 Replace __attribute_noreturn with C++11 [[noreturn]]
This eliminates a configure test, and may help readers understand the
annotation more readily.
2021-06-28 03:37:50 +00:00
Kp 15057af2f9 Replace __noreturn with C++11 [[noreturn]]
This allows non-GNU-C compilers to see the attribute.
2021-06-28 03:37:50 +00:00
Kp 704f8f662d Allow rvalue reference as input to enumerated_iterator 2021-06-28 03:37:50 +00:00
Kp 3466a6f818 Combine partial_range template constructors
Add an explicit check for rvalue ranges that own their storage, and then
allow any other rvalue input.
2021-06-28 03:37:50 +00:00
Kp 028f4f8a56 Use structured bindings to access enumerated ranges 2021-06-28 03:37:50 +00:00
Kp 7b12aac1bb Transpose returned values for enumerate() of non-tuple
Match the order used for tuple.
2021-06-28 03:37:50 +00:00
Kp 212400d140 Convert nm_messagebox_str to use messagebox_newmenu 2021-06-28 03:37:50 +00:00
Kp 9044a19d78 Fold passive_messagebox_item into passive_messagebox 2021-06-28 03:37:50 +00:00
Kp 4c34875c84 Remove unused subfunction_handler
Previous commits eliminated all uses of it.  Remove the unused stubs.
2021-06-28 03:37:50 +00:00
Kp 0c2f95e2cd Remove write-only member window_rendered_data::rear_view 2021-06-28 03:37:50 +00:00
Kp 8a9eb82d6e Factor out choosing bounty target 2021-06-28 03:37:50 +00:00
Kp 63ac8a1f5d Move saved_text out of imenu_specific_type
This significantly shrinks newmenu_item, by not embedding a saved_text
in the union that is present in every newmenu_item.
2021-06-28 03:37:49 +00:00
Kp d0d7545ec1 Unload robot movies on exit 2021-06-28 03:37:49 +00:00
Kp 76a7361786 Close descent.hog on exit
Add RAII wrappers for unmounting PHYSFS paths.  Use them in places that
previously handled unmounting explicitly.  Also, use it for descent.hog
/ descent2.hog, which previously were left mounted indefinitely.
2021-06-28 03:37:49 +00:00
Kp 1dba8e40ec Move PHYSFSX_addRelToSearchPath pathname to caller
Some callers will need access to the computed path.  Change the callers
to pass in a buffer for this path, and have PHYSFSX_addRelToSearchPath
fill that buffer directly.
2021-06-28 03:37:49 +00:00
Kp c98c412fbb Remove template indirection around PHYSFSX_getRealPath
All callers use a std::array<char, PATH_MAX>, so update the definition
to use that.
2021-06-28 03:37:49 +00:00
Kp 391a539ad2 Use enum class for PHYSFSX_addRelToSearchPath append/prepend parameter 2021-06-28 03:37:49 +00:00
Kp 93a7e34caf Move newmenu_item slider storage of saved_text out of line
When other newmenu_item private members also move, this will make
newmenu_item smaller.
2021-06-28 03:37:49 +00:00
Kp 1936b771e1 Construct nm_item_input in place 2021-06-28 03:37:49 +00:00
Kp ef6e36f7ee Move newmenu_item union members into named union 2021-06-28 03:37:49 +00:00
Kp 821e68527d Remove nm_set_item_input overload for char[]
Require use of std::array.  There is no need to support both overloads.
2021-06-28 03:37:49 +00:00
Kp 2a504ee03e Construct nm_item_menu in place 2021-06-28 03:37:49 +00:00