Open
Conversation
Changed to using individual ignitionLevel values (0/1/2/3) Stereo pauses when starter is engaged
fixed typos
Fixed missing symbol and operators
Multiple changes and bugfixes (again)
The `cacheTrackIndex` function was using `#trackFiles` as the modulus when `caching` was enabled. This could result in out-of-bounds indices for the `cachedTracks` array, leading to `obj:cutSFX` not being called on the correct sound object for the currently playing song. This meant the previous song would not stop when the next one started. This change corrects the modulus to `cacheSize`, ensuring that `cacheTrackIndex` always returns a valid index (1 to `cacheSize`) for the `cachedTracks` array. This allows the system to correctly stop the previous song before a new one begins.
This commit addresses an issue where previous songs would continue
playing after a new song started, with the first song only stopping
when a third song began.
The root cause was determined to be an insufficient stop mechanism
for audio tracks. `obj:cutSFX()` alone was not preventing overlap.
The actual stop occurred when `obj:deleteSFXSource()` was called,
which was happening too late via the `updateCache` function (primarily
for tracks that rotated into `cachedTracks[1]`).
The following changes have been implemented:
1. **`nextTrack` and `previousTrack` Modifications:**
* The SFX source of the outgoing track is now explicitly cut
(`obj:cutSFX()`) and then its source deleted
(`obj:deleteSFXSource()`) immediately within these functions
before the track index changes.
* The corresponding `.sfx` entry in `cachedTracks` is set to `nil`.
* Logic has been added to ensure that the incoming track (the
new current track) has a valid SFX object loaded/created in
`cachedTracks` before `systemPlayTrack` is called.
2. **`updateCache` Modifications:**
* Corrected the calculation of `loadIndexInTrackFiles` to ensure
the correct tracks are loaded into the cache when the window slides.
Tracks are now loaded into `cachedTracks[cacheSize]` (for forward)
and `cachedTracks[1]` (for backward) using accurate indices.
* Added robustness checks for nil SFX objects before deletion and
nil table slots before use.
These changes ensure a more aggressive and immediate cleanup of ended
audio sources, and reliable preparation of new ones, preventing overlap.
The `cacheTrackIndex` function was also previously corrected to use
`cacheSize` as its modulus.
This commit addresses several critical errors reported in your logs, including
SimObject naming conflicts and nil reference errors during SFX operations,
while retaining previous fixes for audio overlap.
Key changes:
1. **Standardized SFX SimObject Naming:**
- Introduced a `generateSfxName(filePath)` helper function to create
engine-compliant SimObject names (e.g., "sfx_stereo_filename_ext_mp3")
from full filepaths.
- All calls to `obj:createSFXSource(sfxName, profile, filePath, ...)`
now use `generateSfxName(filePath)` for the `sfxName` (1st argument),
while `filePath` (3rd argument) remains the actual sound file path.
- This resolves `engine::SimObject::assignName` errors caused by
using full paths with '/' as SFX names.
2. **Robust Nil Checks for SFX Operations:**
- Added checks for `track and track.sfx` before calls to
`obj:cutSFX()` and `obj:deleteSFXSource()` in `killStereoSystem`.
- Strengthened conditions in `toggleShuffleMode` before SFX deletion
to ensure `cachedTracks[i]` and `cachedTracks[i].sfx` are valid,
addressing a reported `deleteSFXSource` error.
3. **Refined `cachedTracks` Data Management:**
- Modified `nextTrack` and `previousTrack` to only nullify the
`.sfx` field of a stopped track in `cachedTracks`. The `.name`
field (which stores the original filepath) is now preserved.
- This ensures that functions like `toggleStereoSystem` can reliably
use `cachedTracks[i].name` to retrieve the filepath for recreating
SFXs, fixing an `attempt to index a nil value` error with
`createSFXSource`.
These changes aim to create a more stable and robust stereo system by
correctly managing SFX object lifecycles, naming, and data persistence
within the `cachedTracks` array.
Fixed multiple bugs in code.
Author
|
Just published a fix for a few typos that were found in the code. |
Fixed a few crashes pertaining to various vehicle-related cutSfx events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed fix for the song playing bug when two songs play at the same time.