Commit graph

3761 commits

Author SHA1 Message Date
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