Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 4ac8db1

Browse files
committed
Added extra safety net for multiplayer client receiving unusable sound hashes
1 parent 1c89118 commit 4ac8db1

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

Managers/NetworkClient.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -613,16 +613,20 @@ namespace RTE {
613613
soundContainerToHandle->Stop();
614614
soundContainerToHandle->Reset();
615615
}
616-
soundContainerToHandle->GetTopLevelSoundSet().AddSound(ContentFile::GetPathFromHash(soundDataPointer->SoundFileHash), false);
617-
soundContainerToHandle->SetImmobile(soundDataPointer->Immobile);
618-
soundContainerToHandle->SetAttenuationStartDistance(soundDataPointer->AttenuationStartDistance);
619-
soundContainerToHandle->SetLoopSetting(soundDataPointer->Loops);
620-
soundContainerToHandle->SetPriority(soundDataPointer->Priority);
621-
soundContainerToHandle->SetAffectedByGlobalPitch(soundDataPointer->AffectedByGlobalPitch);
622-
soundContainerToHandle->SetPosition(Vector(soundDataPointer->Position[0], soundDataPointer->Position[1]));
623-
soundContainerToHandle->SetVolume(soundDataPointer->Volume);
624-
soundContainerToHandle->SetPitch(soundDataPointer->Pitch);
625-
soundContainerToHandle->Play();
616+
if (std::string filePathFromHash = ContentFile::GetPathFromHash(soundDataPointer->SoundFileHash); !filePathFromHash.empty()) {
617+
soundContainerToHandle->GetTopLevelSoundSet().AddSound(filePathFromHash, false);
618+
soundContainerToHandle->SetImmobile(soundDataPointer->Immobile);
619+
soundContainerToHandle->SetAttenuationStartDistance(soundDataPointer->AttenuationStartDistance);
620+
soundContainerToHandle->SetLoopSetting(soundDataPointer->Loops);
621+
soundContainerToHandle->SetPriority(soundDataPointer->Priority);
622+
soundContainerToHandle->SetAffectedByGlobalPitch(soundDataPointer->AffectedByGlobalPitch);
623+
soundContainerToHandle->SetPosition(Vector(soundDataPointer->Position[0], soundDataPointer->Position[1]));
624+
soundContainerToHandle->SetVolume(soundDataPointer->Volume);
625+
soundContainerToHandle->SetPitch(soundDataPointer->Pitch);
626+
soundContainerToHandle->Play();
627+
} else {
628+
g_ConsoleMan.PrintString("WARNING: Failed to play sound received from server. Hashed path was invalid for this client.");
629+
}
626630
break;
627631
case AudioMan::SOUND_STOP:
628632
soundContainerToHandle->Stop();

0 commit comments

Comments
 (0)