Commit graph

258 commits

Author SHA1 Message Date
Kp 53d81e78de Fix SDL2 double-free on failure to load music
Fixes: 0142c02edd ("Use Mix_LoadMUSType_RW for named files, too")
2022-09-24 17:47:53 +00:00
Kp ea5d0136dc Pass std::span to msgbox_warning 2022-09-24 17:47:53 +00:00
Kp f175a4508b Pass std::span to ogl_extensions is_ext_supported
This avoids the need to recompute the string's length later.
2022-09-24 17:47:52 +00:00
Kp c09899f457 Pass std::span to load_mus_data 2022-09-24 17:47:52 +00:00
Kp e911d14808 Reduce scope of mix_play_file full_path
It is only set or used when expanding home directory references.  Reduce
its scope accordingly.
2022-09-24 17:47:52 +00:00
Kp a70188e7a5 Move various static functions into anonymous namespace 2022-07-09 13:39:29 +00:00
Kp 0142c02edd Use Mix_LoadMUSType_RW for named files, too
When a file name is available, use SDL_RWFromFile + Mix_LoadMUSType_RW,
rather than calling Mix_LoadMUS(filename).  This allows the calling code
to be more consistent.
2022-03-19 22:55:58 +00:00
Kp f5e9daf7a5 Use Mix_LoadMUSType_RW to unify SDL1/SDL2 call to Mix_LoadMUS_RW
SDL1 defines Mix_LoadMUS_RW as:

```
Mix_LoadMUS_RW(SDL_RWops *rw)
	Mix_LoadMUSType_RW(rw, MUS_NONE, SDL_FALSE);
```

SDL2 defines Mix_LoadMUS_RW as:

```
Mix_LoadMUS_RW(SDL_RWops *src, int freesrc)
	Mix_LoadMUSType_RW(src, MUS_NONE, freesrc);
```

The version with freesrc is preferable, and Rebirth used it to set
freesrc=SDL_TRUE in SDL2 mode.  For SDL1, Rebirth used special logic
in the reset() call to emulate setting freesrc=SDL_TRUE.  SDL1 also
exposes Mix_LoadMUSType_RW, which allows the caller to set freesrc in
both SDL1 and SDL2.  Switch to that, so that the same code is used in
SDL1 and SDL2.
2022-03-19 22:55:58 +00:00
Kp 2099c54ac7 Remove mix_play_file use of PHYSFSX_getRealPath
If the file is accessible via PhysFS, the next branch, based on
PHYSFS_openRead, will find it and use it.  If it is not accessible via
PhysFS, then attempting to resolve its path would fail.  Thus, this
attempt is redundant regardless of whether the file is reachable by
PhysFS.  Remove it.
2022-03-19 22:55:58 +00:00
Kp 3b5b69cb97 Improve error reporting for hmp_open / hmp2mid
Rework the error paths to return path-specific status codes so that the
caller can report exactly which step caused an HMP file to be rejected.
On error, print this reason numerically and, if the reason was a PhysFS
error, also print the PhysFS error code numerically and symbolically.
2022-03-19 22:55:58 +00:00
Kp d34f7b2ad9 Remove unnecessary tests for current_music_type
If the type is not None, an earlier statement will have already
returned.  Thus, the type can be assumed to be None if these test
statements are reached.
2022-03-19 22:55:58 +00:00
Kp d09d30e173 Make mix_play_file only skip hmp for dot-less filenames
Previously, if the filename had no dots, then mix_play_file would refuse
to play it at all.  This was excessive, as only the check for hmp needs
a filename with a dot in it.  Change the logic so that a dot-less file
still is assumed not to be an hmp, but instead of returning, will fall
through and try the other load types.
2022-03-19 22:55:58 +00:00
Kp c4cc119898 Set music type inside load_mus_file
Return the type for compatibility, but set the music type immediately.
Change callers to return without using a switch to set the music type
based on the returned value.  This allows the callers to exit early on a
successful load.

Remove the `switch` in the caller, since now every path that can set
`current_music_type` will either (a) set it to None because the load
failed or (b) set it to non-None and return before reaching the
`switch`.
2022-03-19 22:55:58 +00:00
Kp f8cf0b10c2 Set music type inside load_mus_data
Return the type for compatibility, but set the music type immediately.
Change callers to return without using a switch to set the music type
based on the returned value.  This allows the callers to exit early on a
successful load.
2022-03-19 22:55:58 +00:00
Kp f12abb938e Factor out setting mixer parameters
- Centralize the default value for the hook function.
- Move some static functions to the anonymous namespace.
- Define functions for setting the mixer parameters to ADLMIDI mode and
  SDL_mixer mode, so that these modes can be set from more places.
2022-03-19 22:55:58 +00:00
Kp f51755c2e6 Use enum class for MBTN_* constants 2022-02-27 14:23:53 +00:00
Kp 197a9cbd98 Move joystick interpretation to happen after the event loop
If two or more events are delivered in the same loop, the previous
implementation would count joystick motion multiple times.  Fix this by
moving the joystick interpretation to occur once, after all the events
have been processed.
2022-02-27 14:23:53 +00:00
Kp 78d4a36bb4 Explicitly require support for C++11 constructor inheritance
Parts of the code already used the C++11 syntax, so compilers without it
were already unsupported.  Expand the remaining uses to the standard
syntax.
2022-01-09 15:25:42 +00:00
Kreeblah 522acbf398
Updated enums and added define to silence deprecation warnings 2021-12-22 13:45:35 -08:00
Kp 411e113689 Show current zsh version if it is too low 2021-12-18 03:24:43 +00:00
Kp 4c2fdb7cd7 Use helper functions to always print script name on messages
For errors, also include the string `error: ` and redirect the text to
stderr.
2021-12-18 03:23:37 +00:00
Kp 58e15eaf5c Fix spelling errors in codesign comment 2021-12-18 03:22:51 +00:00
Kreeblah d39d043692
Switch password auth to use an environment variable, to avoid printing it in the SConstruct logs 2021-12-14 21:01:28 -08:00
Kreeblah 8fe7aab673
Add comments about how the notarization process works 2021-12-13 21:18:19 -08:00
Kreeblah 18d19dac16
Removed extraneous double quotes 2021-12-12 16:49:27 -08:00
Kreeblah 9115019fbe
Added comments to shell script 2021-12-12 16:38:53 -08:00
Kreeblah b696a63190
Updated to pass in binary name instead of using glob 2021-12-12 16:04:31 -08:00
Kreeblah f97d553013
Updated messages 2021-12-12 15:53:41 -08:00
Kreeblah 8d0aa0c6a8
Initial changes from feedback 2021-12-12 15:45:28 -08:00
Kreeblah 065ec3c4db
Remove unusd function 2021-12-11 16:01:47 -08:00
Kreeblah 0e735f2197
Added more status messages 2021-12-11 15:59:20 -08:00
Kreeblah 2c5e299140
Fixed message location 2021-12-11 15:56:59 -08:00
Kreeblah 4786427f79
Added signing/notarization script 2021-12-11 15:55:34 -08:00
Kp f99ba91998 Pass user $PATH to Command() for dylibbundler
On some systems, such as the Apple M1 (ARM-based Macs),
dylibbundler is in $PATH, but not in a directory found by the limited
path that SCons uses for Command() invocations.  This causes the SConf
test to succeed (because it uses the full $PATH), but the Command() to
fail (because it uses a reduced path).  Fix this by using the user's
$PATH, if defined, for this Command() invocation.

Along the way, rework tool_bundle.py to use SCons' Node() objects in
place of direct path manipulation.  This lets SCons produce better error
messages in some cases.

Reported-by: Kreeblah <https://github.com/dxx-rebirth/dxx-rebirth/pull/610>
2021-11-08 01:53:05 +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 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 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 028f4f8a56 Use structured bindings to access enumerated ranges 2021-06-28 03:37:50 +00:00
C.W. Betts 48589d0fb0 Add App Category entries to the plists. 2021-04-30 14:43:15 -06:00
dimag0g 6282dd25b9
Merge fbd05a1592 into 8fdc326c2a 2021-02-16 21:30:26 -08:00
C.W. Betts 8fdc326c2a Add CFBundleIdentifier to the plists. 2021-02-07 19:58:12 -07:00
Dmitry Grigoryev fbd05a1592 optimize include files (include what you use) 2021-02-06 21:38:50 +01:00
Kp b0338164f7 Remove SDLMain.m
According to @raptor, this is not needed on modern OSX for SDL1 or SDL2,
and breaks the build on SDL2.  Remove it.

Reported-by: raptor <https://github.com/dxx-rebirth/dxx-rebirth/issues/565>
2021-02-06 17:53:53 +00:00
Kp ae657007fe Remove send_creation_events parameter
It is always nullptr.
2020-10-22 02:26:16 +00:00
Kp 8ec63edcd2 Remove obsolete window_create/callback_window
All users have been converted to inherit and use virtual functions
instead of a callback function.
2020-10-22 02:26:16 +00:00
Kp 295619e633 SDL2: explicitly ignore unwanted key repeats 2020-10-12 03:28:26 +00:00
Kp b3c3066a38 Fix no-joystick build
When joystick support is not present, `event_joystick_get_button` is not
declared in joy.h.

Fixes: c24864b180 ("make menus controllable with joystick")
2020-09-11 03:08:02 +00:00
Kp 0f2c1cdd45 Make game window inherit from dcx::window 2020-08-28 00:18:45 +00:00
Kp 1d3e546848 Inline window_get_canvas
The helper returns a reference to a mutable canvas, so there is no
isolation provided by using the helper.
2020-08-28 00:18:45 +00:00