Commit graph

1091 commits

Author SHA1 Message Date
Kp e7d73e8493 Use RAII to manage SDL_LockAudio state 2023-05-13 15:02:55 +00:00
Kp f2e65abbdb Move d2 movie code into namespace d2x 2023-05-06 19:26:19 +00:00
Kp 1053cb532b Use std::span for MovieFileRead 2023-05-06 19:26:19 +00:00
Kp 53a9ce8823 Use enum class for MVE_sndInit argument 2023-05-06 19:26:19 +00:00
Kp 4bdc31a729 Simplify movie stream ownership
Store an owned pointer in MVEFILE instead of storing an unowned pointer
there and requiring the caller to keep the owned pointer alive for the
lifetime of the MVEFILE.
2023-05-06 19:26:19 +00:00
Kp bb87582a8a Return MVESTREAM from MVE_rmPrepMovie 2023-05-06 19:26:19 +00:00
Kp f39c5e3318 Simplify RotateRobot movie reset
On entry, `pMovie` is not `nullptr`, so `MVE_rmPrepMovie` will call
`mve_reset` and return success.  Inline that path into `RotateRobot`.
2023-05-06 19:26:19 +00:00
Kp 4d0a67ac14 Remove unused MVESTREAM context 2023-05-06 19:26:19 +00:00
Kp 8750b9ae20 Move mvelib timer_created into MVESTREAM 2023-05-06 19:26:19 +00:00
Kp ab56701774 Remove unused arguments to handle_mve_segment_videodata 2023-05-06 19:26:19 +00:00
Kp 7da8304093 Remove unused arguments to handle_mve_segment_setdecodingmap 2023-05-06 19:26:19 +00:00
Kp 2ee7337290 Remove unused arguments to handle_mve_segment_setpalette 2023-05-06 19:26:19 +00:00
Kp 01abb4366e Remove unused arguments to handle_mve_segment_initvideomode 2023-05-06 19:26:19 +00:00
Kp cc83ee76e3 Remove unused arguments to handle_mve_segment_audioframedata 2023-05-06 19:26:19 +00:00
Kp 4d4a66ca38 Remove unused arguments to handle_mve_segment_displayvideo 2023-05-06 19:26:19 +00:00
Kp f83361f91f Remove unused arguments to handle_mve_segment_initvideobuffers 2023-05-06 19:26:19 +00:00
Kp d69daa609b Remove unused arguments to handle_mve_segment_startstopaudio 2023-05-06 19:26:19 +00:00
Kp f33b99e22c Remove unused arguments to handle_mve_segment_initaudiobuffers 2023-05-06 19:26:19 +00:00
Kp 0905aa6002 Remove unused arguments to handle_mve_segment_createtimer 2023-05-06 19:26:19 +00:00
Kp cfda77a03e Remove unused arguments to handle_mve_segment_endofchunk 2023-05-06 19:26:19 +00:00
Kp 61268545ff Remove unused arguments to handle_mve_segment_endofstream 2023-05-06 19:26:19 +00:00
Kp 6c41168e4d Call movie handlers directly via switch
Remove the use of function pointers, since there is only one set of
destinations.
2023-05-06 19:26:19 +00:00
Kp cd604744da Use explicitly defaulted destructor for MVEFILE 2023-04-23 21:45:31 +00:00
Kp d9f2d6d08c Use enum class for mve_opcode 2023-04-23 21:45:31 +00:00
Kp e85270c079 Remove unused MVE_rmPrepMovie parameter track
This was never inspected.  Change callers not to pass it.
2023-04-23 21:45:31 +00:00
Kp 697ef5c32a Use std::array for last_palette_loaded_pig 2023-04-15 19:11:14 +00:00
Kp 0b066d23b4 Use enum class for load_palette arguments 2023-04-15 19:11:14 +00:00
Kp fcca2693f9 Use uint8_t for movie::paused 2023-04-15 19:11:14 +00:00
Kp 132612de35 Use enum class for wall_is_doorway_mask 2023-01-29 20:42:03 +00:00
Kp 407ab585a8 Move window existence flag to a mixin, and track using std::shared_ptr
gcc-12 does enough escape analysis to notice that
newmenu::process_until_closed stores the address of a stack local into a
heap-allocated structure, but not enough analysis to notice that the
stack variable always outlives the escaped address.  The compiler then
warns about the address escaping the local scope.  Reworking the calling
code not to do this is somewhat invasive, and gcc seems unlikely to
change behavior.  Switch to a less efficient implementation that does
not provoke a compiler warning:

- Store a shared_ptr<bool> in the object
- In the object's destructor, write through the pointer to clear the
  shared boolean
- In the caller, store a copy of the shared_ptr<bool> as a local, and
  use that copy to monitor the shared boolean

This is similar to a change proposed by JoeNotCharles
<10a2b2d337>,
but differs in its details.  Among other things, this version takes the
opportunity to move the variable out to a mixin, so that only windows
which expect to be tracked can be tracked.  Previously, all windows were
capable of this, even though most never needed it.
2023-01-14 19:05:37 +00:00
Kp 165b50bcc7 Use mve_audio_spec to track whether audio can play
This is nullptr in all the cases that audio is disabled, and non-nullptr
in all the cases where it is enabled.  Use it instead of a separate flag
variable.
2023-01-07 22:17:31 +00:00
Kp 095b19e450 Use standard new[]/delete[] for movie audio buffer 2023-01-07 22:17:31 +00:00
Kp 7b602efedc Pass std::span to mveaudio_uncompress 2023-01-07 22:17:31 +00:00
Kp 5700cc28e7 Pass std::span to decodeFrame16 2023-01-07 22:17:31 +00:00
Kp 870c85ceab Pass std::span to decodeFrame8 2023-01-07 22:17:31 +00:00
Kp 38ff4a7b19 Use std::span for MVE g_pCurMap, g_nMapLength 2023-01-07 22:17:31 +00:00
Kp e6bba24737 Disable MVE mixer when movie ends
The global variables that control it configure the callback to do
nothing, but SDL_mixer would still call it and still acquire the SDL
mutex that protects the call.  Such calls are a waste, so disable them.
This should also fix
<https://github.com/dxx-rebirth/dxx-rebirth/issues/684>, which appears
to be caused by the MVE mixer callback being run during gameplay, and
the callback not returning immediately.  This is suspected to be because
a race condition between MVE_rmEndMovie and the callback caused the
global variables not to be placed in a state that causes the callback to
return immediately.
2022-12-17 13:16:28 +00:00
Kp a00a1ce59a Use mve_audio_spec to detect whether MVE audio has been created 2022-12-10 18:09:54 +00:00
Kp 3d5de92058 Fix OS X clang build
OS X still uses clang-14, which lacks sufficient std::ranges support for
recent Rebirth changes.

- Rewrite uses of std::ranges::SYMBOL to ranges::SYMBOL
- Add a stub header that, on gcc, provides for each SYMBOL a statement
  `using std::ranges::SYMBOL;`, to delegate back to the standard library
  implementation.
- On clang, define a minimal implementation of the required symbols,
  without constraint enforcement.  Compile-testing with gcc will catch
  constraint violations.

Once OS X clang ships a standard library with the required features,
this stub header will be removed and the uses changed back to their full
names.
2022-10-31 00:51:32 +00:00
Kp 7fc6879555 Fix various Win32 build failures due to ambiguous operator[]()
gcc reports:

```
ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second
```

Fix the ambiguity by using an unsigned integer constant.
2022-10-23 23:00:24 +00:00
Kp e385ff1c3b Use std::ranges::find_if instead of std::find_if
std::ranges::find_if permits use of a sentinel instead of a full
iterator, and supports std::ranges::find as an alternative to certain
simple uses of std::find_if.

Where possible, use the form that takes a range, rather than the form
that takes two iterators.

Add a declared, but not defined, default constructor for
self_return_iterator to satisfy the standard library's concept
`semiregular`, which insists that sentinels be default-constructible,
even for those functions that never need to do so.

Add a defined, but unused, operator++(postfix) for zip_iterator to
satisfy a standard library concept for `forward_iterator`.
2022-10-09 23:15:20 +00:00
Kp 0ebcc64ac5 Test whether change_filename_extension succeeded before using its output 2022-10-09 23:15:20 +00:00
Kp a9142bb65a Use std::span for change_filename_extension arguments 2022-10-09 23:15:20 +00:00
Kp 1d475d106c Use std::span for init_subtitles argument filename 2022-10-09 23:15:20 +00:00
Kp 38adcc7729 Simplify change_filename_extension
The called function skipped over a leading dot in the extension.  Remove
that logic and change all callers not to supply a leading dot.
2022-10-09 23:15:20 +00:00
Kp 1365d0796c Use std::span for RunMovie argument subtitles 2022-10-02 19:51:35 +00:00
Kp 1101b02f84 Use std::span for PlayMovie argument subtitles 2022-10-02 19:51:35 +00:00
Kp 81b77d2f28 Pass std::span to create_bfs_list 2022-09-24 17:47:53 +00:00
Kp ad7057be87 Add hack for case mismatch in Vertigo robot movies
PhysFS 3 is case-sensitive for movie filename lookup.  The consequence
of this was first reported in [1].  In [2], @icculus stated this was a
bug in PhysFS 3 that would be fixed in PhysFS 3.0.2.  However, [3] and
[4] assert that the fix was never included.  The existence of [5] seems
to support this.  The original problem was reported in 2019.  As of
2022, user @AlumiuN, running PhysFS 3.0.2, is affected.  Therefore, this
commit adds code to detect the relevant robot movies and adjust the case
in the Rebirth code.

[1]: https://github.com/dxx-rebirth/dxx-rebirth/issues/379
[2]: https://github.com/dxx-rebirth/dxx-rebirth/issues/379#issuecomment-389400528
[3]: https://github.com/dxx-rebirth/dxx-rebirth/issues/379#issuecomment-462083489
[4]: https://github.com/dxx-rebirth/dxx-rebirth/issues/379#issuecomment-477790175
[5]: https://github.com/dxx-rebirth/dxx-rebirth/issues/644
2022-09-24 17:47:52 +00:00
Kp 9fa97573c4 Move RoboFile to briefing scope 2022-09-24 17:47:52 +00:00