Commit graph

11445 commits

Author SHA1 Message Date
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 71ed303c27 Fix clang editor medwall build
The existing code checks that w.m_ptr is not nullptr before using it.
clang's flow analysis is unable to prove that w.m_ptr does not become
nullptr after it was first checked, even though `w` is const.  This
causes clang to include calls to null_pointer_exception::report, which
is not instantiated for wall.  That in turn causes a link error.

Rewrite the code to let clang see that the value tested is the value
used, and that no nullptr dereference can happen here.
2021-09-04 12:17:14 +00:00
Kp fdf5836031 Move g3 instance contexts onto the stack 2021-09-04 12:17:14 +00:00
Kp 6a1f5937a2 Change ogl_font_choose_size to return width/height 2021-09-04 12:17:14 +00:00
Kp 4c681c40fd Factor out the slider font smoothing hack
Move the test from the innermost loop to one layer farther out, since it
was conditional on two specific passes of the innermost loop.
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 1354099b0d Move Computed_colors into gr_find_closest_color
- Inline add_computed_color into gr_find_closest_color, and then only
  one function will need access to Computed_colors.
- Allow the recent-choice bubble-up logic to apply to all elements
- If all entries are in use, always overwrite the last element in
  Computed_colors instead of picking one randomly.
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 347b8d9f77 Factor out palette color search code 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 35c7684200 Cache text color change control code
This generates the same code in an optimized build, but makes the intent
clearer.
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 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 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 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 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 9dca02a723 Report libpng version information in -verbose startup output 2021-08-31 02:20:06 +00:00
Kp 6fb57c2dc2 Update snapshot ebuild 2021-08-26 03:13:46 +00:00
Kp fb254d3986 Update PYTHON_COMPAT in Gentoo ebuild
Python 3.9 is now standard, and is used for running SCons.  Update
PYTHON_COMPAT accordingly.
2021-08-26 03:13:46 +00:00
Kp 2c3a258d17 Fix bogus clang -Wunused-variable warning 2021-08-26 03:13:46 +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 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 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 f047629051 Move glow special-case above g3_check_normal_facing
Checking the glow special case should be cheaper than computing and
checking the normal, so check the glow case first.  Also, when the glow
values are defined, cache the result of reading from it to avoid
repeating the indexing logic farther down.
2021-08-26 03:13:45 +00:00
Kp f9ed412ba6 Move use of SQUARE into a helper
Give the compiler discretion over whether to inline the multiplications.
2021-08-26 03:13:45 +00:00
Kp 172c183d83 Reduce scope of font rendering variables 2021-08-26 03:13:45 +00:00