MCPcopy Create free account
hub / github.com/JACoders/OpenJK / AS_UpdateSetVolumes

Function AS_UpdateSetVolumes

code/client/snd_ambient.cpp:914–958  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

912*/
913
914static void AS_UpdateSetVolumes( void ) {
915 if ( !aSets ) {
916 return;
917 }
918
919 //Get the sets and validate them
920 ambientSet_t *current = aSets->GetSet( currentSet );
921 if ( !current ) {
922 return;
923 }
924
925 float scale;
926 int deltaTime;
927 if ( current->masterVolume < MAX_SET_VOLUME ) {
928 deltaTime = cls.realtime - current->fadeTime;
929 scale = ((float)(deltaTime)/(float)(crossDelay));
930 current->masterVolume = (int)((scale) * (float)MAX_SET_VOLUME);
931 }
932
933 if ( current->masterVolume > MAX_SET_VOLUME ) {
934 current->masterVolume = MAX_SET_VOLUME;
935 }
936
937 //Only update the old set if it's still valid
938 if ( oldSet == -1 ) {
939 return;
940 }
941
942 ambientSet_t *old = aSets->GetSet( oldSet );
943 if ( !old ) {
944 return;
945 }
946
947 //Update the volumes
948 if ( old->masterVolume > 0 ) {
949 deltaTime = cls.realtime - old->fadeTime;
950 scale = ((float)(deltaTime)/(float)(crossDelay));
951 old->masterVolume = MAX_SET_VOLUME - (int)((scale) * (float)MAX_SET_VOLUME);
952 }
953
954 if ( old->masterVolume <= 0 ) {
955 old->masterVolume = 0;
956 oldSet = -1;
957 }
958}
959
960/*
961-------------------------

Callers 1

AS_UpdateCurrentSetFunction · 0.70

Calls 1

GetSetMethod · 0.45

Tested by

no test coverage detected