Commit graph

1554 commits

Author SHA1 Message Date
Kp ba01b2bdc1 Convert some math functions to fixang
The value was always truncated internally anyway.  Move the truncation
to the call boundary, since most callers started with a fixang.
2021-11-01 03:37:20 +00:00
Kp 57780e0450 Move window_is_visible,window_set_visible to be window methods
Shrink w_visible to uint8_t.  Move it to pack better.
2021-11-01 03:37:18 +00:00
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 21c530a3e2 Use enumerated_array for difficulty-level-specific arrays 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 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 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 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 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 48a3ac2c53 Lift ogl_start_frame eye handling into caller 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 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 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 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 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 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 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 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 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 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 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 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