mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-15 06:08:35 +00:00
AGS: Store clip's ID in SOUNDCLIP instead of a pointer to unknown type
From upstream 954e9bb27e7aea873931ba20ad89397d4dc004bd
This commit is contained in:
parent
c25b08448d
commit
07f36ce19b
@ -27,7 +27,7 @@
|
||||
#include "ags/shared/game/room_struct.h"
|
||||
#include "ags/engine/script/runtime_script_value.h"
|
||||
#include "ags/engine/media/audio/audio_system.h"
|
||||
|
||||
#include "ags/shared/ac/game_setup_struct.h"
|
||||
#include "ags/shared/debugging/out.h"
|
||||
#include "ags/engine/script/script_api.h"
|
||||
#include "ags/engine/script/script_runtime.h"
|
||||
@ -80,8 +80,8 @@ void AudioChannel_SetPanning(ScriptAudioChannel *channel, int newPanning) {
|
||||
ScriptAudioClip *AudioChannel_GetPlayingClip(ScriptAudioChannel *channel) {
|
||||
auto *ch = AudioChans::GetChannelIfPlaying(channel->id);
|
||||
|
||||
if (ch) {
|
||||
return (ScriptAudioClip *)ch->_sourceClip;
|
||||
if (ch && ch->_sourceClipID >= 0) {
|
||||
return &_GP(game).audioClips[ch->_sourceClipID];
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ int AudioClip_GetIsAvailable(ScriptAudioClip *clip) {
|
||||
void AudioClip_Stop(ScriptAudioClip *clip) {
|
||||
for (int i = NUM_SPEECH_CHANS; i < _GP(game).numGameChannels; i++) {
|
||||
auto *ch = AudioChans::GetChannelIfPlaying(i);
|
||||
if ((ch != nullptr) && (ch->_sourceClip == clip)) {
|
||||
if ((ch != nullptr) && (ch->_sourceClipID == clip->id)) {
|
||||
AudioChannel_Stop(&_G(scrAudioChannel)[i]);
|
||||
}
|
||||
}
|
||||
|
@ -347,8 +347,8 @@ HSaveError WriteAudio(Stream *out) {
|
||||
// Audio clips and crossfade
|
||||
for (int i = 0; i < TOTAL_AUDIO_CHANNELS; i++) {
|
||||
auto *ch = AudioChans::GetChannelIfPlaying(i);
|
||||
if ((ch != nullptr) && (ch->_sourceClip != nullptr)) {
|
||||
out->WriteInt32(((ScriptAudioClip *)ch->_sourceClip)->id);
|
||||
if ((ch != nullptr) && (ch->_sourceClipID >= 0)) {
|
||||
out->WriteInt32(ch->_sourceClipID);
|
||||
out->WriteInt32(ch->get_pos());
|
||||
out->WriteInt32(ch->_priority);
|
||||
out->WriteInt32(ch->_repeat ? 1 : 0);
|
||||
|
@ -222,7 +222,7 @@ SOUNDCLIP *load_sound_clip(ScriptAudioClip *audioClip, bool repeat) {
|
||||
}
|
||||
if (soundClip != nullptr) {
|
||||
soundClip->set_volume_percent(audioClip->defaultVolume);
|
||||
soundClip->_sourceClip = audioClip;
|
||||
soundClip->_sourceClipID = audioClip->id;
|
||||
soundClip->_sourceClipType = audioClip->type;
|
||||
}
|
||||
return soundClip;
|
||||
@ -742,7 +742,7 @@ int calculate_max_volume() {
|
||||
void apply_volume_drop_modifier(bool applyModifier) {
|
||||
for (int i = NUM_SPEECH_CHANS; i < _GP(game).numGameChannels; i++) {
|
||||
auto *ch = AudioChans::GetChannelIfPlaying(i);
|
||||
if (ch && ch->_sourceClip != nullptr) {
|
||||
if (ch && ch->_sourceClipID >= 0) {
|
||||
if (applyModifier)
|
||||
apply_volume_drop_to_clip(ch);
|
||||
else
|
||||
|
@ -25,7 +25,7 @@
|
||||
namespace AGS3 {
|
||||
|
||||
SOUNDCLIP::SOUNDCLIP() : _panning(12. / 8), _panningAsPercentage(0),
|
||||
_sourceClip(nullptr), _sourceClipType(0), _speed(1000), _priority(50),
|
||||
_sourceClipID(-1), _sourceClipType(0), _speed(1000), _priority(50),
|
||||
_xSource(-1), _ySource(-1), _maximumPossibleDistanceAway(0), _muted(false),
|
||||
_volAsPercentage(0), _vol(0), _volModifier(0), _repeat(false), _directionalVolModifier(0) {
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ struct SOUNDCLIP {
|
||||
int _maximumPossibleDistanceAway;
|
||||
int _directionalVolModifier;
|
||||
bool _repeat;
|
||||
void *_sourceClip; // Pointer to source object that spawned the clip
|
||||
int _sourceClipID;
|
||||
|
||||
virtual void poll() = 0;
|
||||
virtual void destroy() = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user