113 Commits
Author SHA1 Message Date
BMagnu 6b43cabff6 Fix CTD when an interface sound is shared with a gameplay sound (#7488) 2026-05-30 23:45:22 +02:00
Goober5000 b2c44e1a71 clarify which sound type is being parsed when warning about retail-style sounds 2025-02-22 21:12:58 -05:00
Goober5000 b72d67c074 default to using Vasudan ambient sound in the Vasudan main hall 2024-11-14 19:30:19 -05:00
Goober5000 56fc5b457f Merge pull request #6352 from Goober5000/allow_explicitly_empty_sounds
allow explicitly empty sounds
2024-09-17 22:27:56 -04:00
Goober5000 d67fe30982 retail-style warning fix
The warning for mismatched names-and-indexes implicitly assumed that retail-style sounds would only be added with numeric indexes.  Since adding named sounds in the retail style is, in fact, allowed, update the logic to not warn in that case.

Fixes #6354.
2024-09-16 23:39:58 -04:00
Goober5000 b596fa305d allow explicitly empty sounds
Make sounds that are specified as "empty" or "none" in sounds.tbl ineligible for treatment as placeholder sounds.  Resolves #6350.
2024-09-13 16:42:13 -04:00
Goober5000 ee9770d418 properly fill sounds into placeholder slots 2024-09-05 02:36:49 -04:00
Goober5000 9d6c8509ab proactively set placeholder sounds to invalid 2024-09-05 02:36:28 -04:00
Goober5000 854b0139d2 fix sound initialization (#6333)
Fix a small oversight from #6112.  In the empty/placeholder indexed sound situation, although the sound should not be appended (since it indexed), it should still be treated as a new sound, in order for all the first-parse and first-initialize logic to run properly.  Set the right value and add some comments to illuminate the logic.
2024-08-30 08:42:33 -04:00
Goober5000 c8aa28b1cc follow-up to probability curves
Fix the inadvertent swapping of the two utility functions for parsing sounds.  While we're at it, streamline a few lines, remove a few C-style casts, and remove an unused function prototype.

Follow-up to #6314.  Fixes a crash encountered by Inferno on 24.2-RC1.
2024-08-27 23:30:25 -04:00
Kestrellius 91a673ac58 Generic random distributions, including curve-based (#6314)
* Adds PDF to CDF function.

* Further implementation; not complete

* Implements curve integration.

* Implements binary search.

* Finalizes random-range reorganization

* Extends generic range support to various things.

* Removes infinities.

* Fixes bugs.

* Adds handling of invalid prob curves.

* Adjusts warning.

* Exception handling

* Addresses issues raised during review.

* Cleanup

* Appeases clang

* Further appeasement

* even further appeasement

* appeasement^3

* appeasement^4
2024-08-27 00:27:33 +02:00
Goober5000 d16eb20aea improve sounds.tbl index ordering
Although sound indexing is now done by name, mods which index by number (sc. a number that is treated as a name) expect the indexes to be in numeric order.  When multiple levels of -snd.tbm files add mixed retail-style and new-style sounds, this assumption can be violated due to named sounds being placed into indexes that later files expect to be available.

This PR refines the parsing so that sounds which use a numeric index can pre-empt existing named sounds that have been assigned to that index.  Since named sounds can go anywhere, they are just moved to the end of the list.  This allows the ranges 192-199 and 202-249 to be available for numeric indexes as expected under the old style.  MediaVPs named sounds which were previously parsed into those indexes are bumped to the next available index.

Additionally, this PR doubles the range of numbers that are treated as indexes, to more realistically accommodate additional numbered sounds.  (The number/index distinction is rather arbitrary and is primarily used to avoid creating large sections of unused sounds if a mod were to specify a very large number, e.g. 10001, for a sound name.)

Finally, this changes parse warnings to use `error_display()` so that the warning displays the parsed file and line number.
2024-08-08 19:00:20 -04:00
Goober5000 e90416e199 Several coverity fixes (#6232)
* coverity - using `std::move` instead of copying, and change some parameters from value to reference

* coverity - fix or mark potential copy-paste mistakes

* coverity - various checking of parameter and return values

* coverity - miscellaneous fixes, and change some 'intentional' markers to 'false positive' markers
2024-07-06 12:51:31 +02:00
Goober5000 630f479fd9 properly handle game sounds with numeric IDs (#6212)
Patches the gamesnd system in several ways to properly fix the bug identified in #6196.  Due to the way the new sound system was written, sounds with numeric IDs were not necessarily added in their indexed location, even though the code assumed (even prior to #6112) that this would be the case.  The code now uses the proper index for both old *and* new style sounds.  This is done by ensuring, in `gamesnd_parse_entry()`, that the vector contains an entry for the specified numeric ID before doing a search for that ID.

Due to the slightly modified population of the gamesnd vectors, the `Snds_iface_handle` vector is now populated after parsing the various sounds.tbl files rather than during parsing.

Separately, this makes consistent the handling of the `sound_entries` vector which could potentially be empty but also treated an empty state as an assertion failure.
2024-06-27 23:55:42 -04:00
Goober5000 27caca5d2f handle modification of placeholder sounds 2024-05-18 17:34:09 -04:00
Goober5000 e3bdc106f3 fix ballistic primary banks exploding
When game sounds were changed to allow named entries, it became possible for named entries to unexpectedly replace numbered entries.  This was noticed most obviously in the ballistic rearm sound effect, which started using explosions rather than the standard rearm sound effects.  This occurred because MV_Tiny and MV_Small were added into indexes 200 and 201.

To restore the original behavior, the code now prevents sound effects added via TBM from being placed into reserved indexes.  The reserved indexes are instead assigned placeholders, which can subsequently be updated or left alone as the modder prefers.

This also makes the code a bit more robust including patching some sound validity checks in `gamesnd_game_sound_try_load` and `snd_load`.
2024-05-18 17:34:09 -04:00
Goober5000 fbca88d36d add per-species warp effects
This allows warp parameters to be specified in species_defs.tbl, rather than requiring them to be specified for each ship in ships.tbl.  Since this introduces a cyclic dependency between species_defs.tbl and sounds.tbl, the parsing of sounds.tbl is broken into two stages.

Implements request from #5283.
2023-04-10 17:24:38 -04:00
MjnMixael f0ecf8c2aa allow borrowing flyby sounds from a previously parsed species (#4828) 2022-11-01 21:43:01 +09:00
David Gibson e86bbb0138 cleanup to the cleanup of filters
Moved more things to debug filters, and associated cleanup
2022-09-27 10:25:50 -05:00
Goober5000 f469da2606 fix overriding of originally-empty sounds
Follow-up to #3743.  A sound that was originally parsed as empty, but then re-parsed as non-empty, would still have the `GAME_SND_NOT_VALID` flag from the original attempt.  This fixes that by clearing the flag each time the filename is read.
2022-08-23 01:28:12 -04:00
David Gibson 32fe227f6d Removed the cap on enhanced sound +Limit: entirely. 2022-04-16 21:26:44 -05:00
Goober5000 a25363e564 address feedback 2021-10-31 17:55:33 -04:00
Goober5000 71be5b7b80 make gamesnd a little more robust
a) add a new method gamesnd_game_sound_exists
b) add script support for this new method
c) use this method when checking for existence of ballistic rearming sounds
d) prevent "empty" and "none" sounds from triggering warnings
2021-10-31 17:55:33 -04:00
Goober5000 b96d9f6e62 address feedback 2021-09-04 15:46:03 -04:00
Joshua Glatt 144d484c85 Replace rand() calls with a Random class (#3332) 2021-05-04 18:26:06 -07:00
Goober5000 a3c5186635 add missing newlines in several mprintf statements (#3409)
Fixes #3407, and I used a regex search to find what I hope are all other examples.
2021-05-02 23:53:40 -04:00
asarium 8f88801646 Add dynamic action programming system
This system adds the code necessary for letting content creators specify
complex events by specifying a simple, program-like sequence of
operations that will be executed by the engine when a certain event is
triggered.
2021-02-21 21:29:02 +01:00
Asteroth 83bd14586f Merge pull request #3179 from Baezon/empty-sound-fix
Don't search for empty sound names
2021-02-03 17:41:08 -05:00
Baezon f95e51b047 dont search for empty names 2021-01-30 00:05:17 -05:00
Baezon f9e44f545e ignore empty sounds 2021-01-27 23:31:38 -05:00
Goober5000 02cdb106ba convert number parsing to use atoi and strtof
One small detail that was overlooked in PR #3021... KeldorKatarn's old code used `strtod` while the new code used `stuff_float`.  This wouldn't be a problem except that a couple MVP models use annoyingly formatted floats like 8.9e-08.  So I decided to convert `stuff_float` to use `strtof` and do some more upgrades while I was at it.
2021-01-08 09:25:25 -05:00
Goober5000 41df46a14e make sound lookup case-insensitive 2020-08-28 10:32:24 -04:00
Goober5000 06c6434d44 debris ambient sounds, optional ship sounds, begin collision sounds 2020-08-08 13:49:06 -04:00
Goober5000 44b7d5a4bd refactor parsing of flyby sounds to make them optional 2020-03-23 20:27:28 -04:00
asarium ad54f588bb Use strongly typed handles for sound handles
This is similar to the other changes I already posted. Here the sound
instance handles are converted to their own handle type which will make
it easier to use the sound API.
2018-07-16 10:21:52 +02:00
asarium 9dfb8faea3 Use strongly-typed handles for sound entries
This converts the previous int handles to a strongly-typed wrapper
handle which will make the API more self-documenting and will ensure
that wrongly used handles are detected at compile time.

I already found a few mistakes with these changes which I also fixed
here.
2018-07-03 10:43:10 +02:00
asarium b5bb5097b9 Make sure that sound pitch range is initialized properly
If a sound did not receive a valid sound name then the parsing function
would exit early and not set the pitch range properly. This would cause
a divide by zero if the duration of the sound was queried.

This moves the initialization of the pitch range to the start of the
parsing functions which makes sure that the range is initialized even if
the function exits early.
2018-06-27 17:23:13 +02:00
asarium eeed22b91a Enable misc-unused-parameters
clang-tidy was used for fixing the warnings. It is not clear if this is
actually an improvement so this may still be disabled later.
2018-04-25 11:57:55 +02:00
asarium e28ebc2a6c Enable and fix misc-suspicious-string-compare check 2018-04-25 11:13:19 +02:00
asarium dcac9e7223 Enable more misc- checks 2018-04-25 11:12:41 +02:00
asarium 0b4ca71eba Enable modernize-deprecated-headers 2018-04-25 11:12:41 +02:00
asarium 8f06e338a4 Add typesafe handle types and use it in game sound system
This adds a new class which allows to create type safe resource handle
types. At the moment, the engine uses ints pretty much everywhere for
providing handles to resources created by the specific subsystems. Since
all ints are the same to the C/C++ typesystem it is perfectly legal to
pass a sound handle to the graphics API as a buffer handle which will
obviously cause issues.

This adds a new type called "ID" which is a wrapper class for a generic
handle but with added type safety. An instance of this class cannot be
passed to a function expecting another type of handle which provided
compile-time type safety for these APIs.

As an initial test I converted the game sound handles to this new type.
I already found a bug in the mainhall system thanks to this new type.
The mainhall used the game sound handles as sound instance handles which
probably meant that that specific code never really worked right. I
removed the code since there was no better alternative for fixing it.
2018-04-22 16:22:45 +02:00
asarium 5a5dbd0df2 Load unloaded sounds when trying to determine sound length
This can happen if a script tries to determine the length of a sound
before actually playing it. This fixes the assertion by loading the
sound when it is necessary.
2018-03-04 22:41:15 +01:00
asarium 0ff8a2c159 Add support for multiple sounds in one game sound entry
This adds support for specifying multiple sounds for a single game sound
entry. The engine then selects which sound will be played based on the
strategy provided by the game data. This required a few changes to some
of the game code since previously every game sound had exactly one sound
file attached to it. The most notable change is that it is no longer
possible to determine the exact duration a sound can have so instead the
new code computes the maximum duration a sound can have and uses that
where appropriate.

This also adds support for randomizing the pitch and volume of the sound
to provide a more varied experience even if only a single sound is used.

One possible issue that exists is that the "sequential" strategy only
works globally at the moment so if two sources use the same game sound
concurrently then the two sources will share the sequence of sounds
since there is no sound instance data at the moment. That can be added
in a future change but should not present a huge issue for most
use-cases.

Visual Studio on Appveyor somehow causes deprecation error on _our_
definition of vsprintf. I have no idea why these changes introduced this
warning but I won't debug Visual Studio compiler bugs that I can't
reproduce with my Visual Studio version so I just disabled those
warnings.
2017-10-17 10:57:22 +02:00
asarium 8272304cfa Remove global Snds and Snds_iface vector 2017-10-17 10:30:00 +02:00
asarium 0522566790 Replace direct usages of Snds vector with a function call
This will make it easier to validate the used handles and is generally
better since it doesn't require a global sounds vector.
2017-10-09 15:02:29 +02:00
asarium abdef9f7b0 Add tracing scopes to the mission load code
This makes it easier to determine what takes the most time while loading
the mission (loading models) and how we could optimize that load time
(optimize model loading).

This is not a bug fix but it also shouldn't cause any regressions since
there are no actual code changes so this could be merged before the
release of 3.8.
2017-03-28 17:23:22 +02:00
MageKing17 bce17561ed Change pointless .size() calls into .empty() calls.
The codebase had quite a few instances of .size() being called and then checked to see if it was 0 or not (or less than 1, or greater-than-or-equal-to 1, which are basically equivalent), when .empty() could be called instead (negated or not, depending on what the original condition was).
2016-09-07 18:36:12 -07:00
Goober5000 e11f6904b4 retail sounds 36 and 37 should actually be converted to 3D 2015-11-28 00:27:27 -05:00
Goober5000 8a125ab019 remove obsolete const_casts 2015-10-28 00:18:31 -04:00