Skip to content

Commit

Permalink
fix bug which can under certain circumstances lead to NullReferenceEx…
Browse files Browse the repository at this point in the history
…ception
  • Loading branch information
Thiago Zimmermann committed Nov 1, 2019
1 parent bf6cf45 commit 959f616
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Hypnonema.Client/Players/VideoPlayer2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,15 @@ public async Task OnTick()
this.Draw();

var entity = GetClosestObjectOfType(this.SoundMaxDistance, (uint)this.RenderTarget.Hash);
if (entity == null)
{
this.Browser.SendVolume(0f);
return;
}

var distance = World.GetDistance(Game.PlayerPed.Position, entity.Position);

if (distance >= this.SoundMaxDistance || entity == null)
if (distance >= this.SoundMaxDistance)
{
this.Browser.SendVolume(0f);
}
Expand Down

0 comments on commit 959f616

Please sign in to comment.