Adjusts handling for special-case networking of sound assets where we may need to account for stuff like SFXPlaylists. DB names aren't transported, so we need to do Id lookups

This commit is contained in:
JeffR 2022-06-04 00:59:06 -05:00
parent 448a453e51
commit 7efab038d1
3 changed files with 105 additions and 21 deletions

View file

@ -258,7 +258,7 @@ ShapeBaseImageData::ShapeBaseImageData()
stateShapeSequence[i] = 0;
stateScaleShapeSequence[i] = false;
INIT_ASSET_ARRAY(stateSound, i);
INIT_SOUNDASSET_ARRAY(stateSound, i);
stateScript[i] = 0;
stateEmitter[i] = 0;
stateEmitterTime[i] = 0;
@ -588,17 +588,32 @@ void ShapeBaseImageData::handleStateSoundTrack(const U32& stateId)
s.sound = getstateSoundAsset(stateId);
if (s.sound == NULL && mstateSoundName[stateId] != StringTable->EmptyString())
if (s.sound == NULL)
{
//ok, so we've got some sort of special-case here like a fallback or SFXPlaylist. So do the hook-up now
SFXTrack* sndTrack;
if (!Sim::findObject(mstateSoundName[stateId], sndTrack))
if (mstateSoundName[stateId] != StringTable->EmptyString())
{
Con::errorf("ShapeBaseImageData::onAdd() - attempted to find sound %s but failed!", mstateSoundName[stateId]);
//ok, so we've got some sort of special-case here like a fallback or SFXPlaylist. So do the hook-up now
SFXTrack* sndTrack;
if (!Sim::findObject(mstateSoundName[stateId], sndTrack))
{
Con::errorf("ShapeBaseImageData::onAdd() - attempted to find sound %s but failed!", mstateSoundName[stateId]);
}
else
{
s.soundTrack = sndTrack;
}
}
else
else if (mstateSoundSFXId[stateId] != 0)
{
s.soundTrack = sndTrack;
SFXTrack* sndTrack;
if (!Sim::findObject(mstateSoundSFXId[stateId], sndTrack))
{
Con::errorf("ShapeBaseImageData::onAdd() - attempted to find sound %i but failed!", mstateSoundSFXId[stateId]);
}
else
{
s.soundTrack = sndTrack;
}
}
}
}
@ -1172,7 +1187,7 @@ void ShapeBaseImageData::packData(BitStream* stream)
}
}
PACKDATA_ASSET_ARRAY(stateSound, i);
PACKDATA_SOUNDASSET_ARRAY(stateSound, i);
}
stream->write(maxConcurrentSounds);
stream->writeFlag(useRemainderDT);
@ -1377,7 +1392,7 @@ void ShapeBaseImageData::unpackData(BitStream* stream)
else
s.emitter = 0;
UNPACKDATA_ASSET_ARRAY(stateSound, i);
UNPACKDATA_SOUNDASSET_ARRAY(stateSound, i);
handleStateSoundTrack(i);
}
}