Remove superflous null checks

and cache a dictionary lookup.
This commit is contained in:
Matthias Mailänder
2021-12-13 20:03:32 +01:00
committed by abcdefg30
parent eb4de47362
commit 718bf88b9a

View File

@@ -395,7 +395,7 @@ namespace OpenRA
if (currentNotifications.ContainsKey(name)) if (currentNotifications.ContainsKey(name))
{ {
var currentNotification = currentNotifications[name]; var currentNotification = currentNotifications[name];
if (currentNotification != null && !currentNotification.Complete) if (!currentNotification.Complete)
{ {
if (pool.AllowInterrupt) if (pool.AllowInterrupt)
soundEngine.StopSound(currentNotification); soundEngine.StopSound(currentNotification);
@@ -403,13 +403,17 @@ namespace OpenRA
return false; return false;
} }
} }
else if (currentSounds.ContainsKey(actorId) && !currentSounds[actorId].Complete) else if (currentSounds.ContainsKey(actorId))
{
var currentSound = currentSounds[actorId];
if (!currentSound.Complete)
{ {
if (pool.AllowInterrupt) if (pool.AllowInterrupt)
soundEngine.StopSound(currentSounds[actorId]); soundEngine.StopSound(currentSound);
else else
return false; return false;
} }
}
var volume = InternalSoundVolume * volumeModifier * pool.VolumeModifier; var volume = InternalSoundVolume * volumeModifier * pool.VolumeModifier;
var sound = soundEngine.Play2D(sounds[name], false, relative, pos, volume, attenuateVolume); var sound = soundEngine.Play2D(sounds[name], false, relative, pos, volume, attenuateVolume);