Skip to content

Commit

Permalink
fix bug where oofaudiopolling will crash bc i didnt initialize deadpl…
Browse files Browse the repository at this point in the history
…ayslist first
  • Loading branch information
codelastnight committed Jul 19, 2024
1 parent efe8655 commit ef49828
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions OofPlugin/DeadPlayersList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ private void AddRemoveDeadPlayer(DeadPlayer deadPlayer, uint currentHp, uint obj
else if (currentHp != 0 && DeadPlayers.Any(x => x.PlayerId == objectId))
{
DeadPlayers.RemoveAll(x => x.PlayerId == objectId);

}
}
/// <summary>
Expand All @@ -40,8 +41,8 @@ public void AddRemoveDeadPlayer(IPlayerCharacter character)
{
if (character == null) return;

var deadPlayer = new DeadPlayer { PlayerId = character.EntityId };
AddRemoveDeadPlayer(deadPlayer, character.CurrentHp, character.EntityId);
var deadPlayer = new DeadPlayer { PlayerId = character.DataId };
AddRemoveDeadPlayer(deadPlayer, character.CurrentHp, character.DataId);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion OofPlugin/OofPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public OofPlugin(IDalamudPluginInterface pluginInterface)
Configuration = pluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
Configuration.Initialize(pluginInterface);

SoundManager = new SoundManager(this);
DeadPlayersList = new DeadPlayersList();
SoundManager = new SoundManager(this);


ConfigWindow = new ConfigWindow(this);
Expand Down
7 changes: 5 additions & 2 deletions OofPlugin/SoundManager.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using NAudio.Wave;
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -122,7 +121,9 @@ private async Task OofAudioPolling(CancellationToken token)
{
await Task.Delay(200, token);
if (token.IsCancellationRequested) break;
if (!DeadPlayersList.DeadPlayers.Any()) continue;

if (DeadPlayersList == null) continue;
if (DeadPlayersList.DeadPlayers.Count == 0) continue;
if (Dalamud.ClientState!.LocalPlayer! == null) continue;
foreach (var player in DeadPlayersList.DeadPlayers)
{
Expand All @@ -139,7 +140,9 @@ private async Task OofAudioPolling(CancellationToken token)
break;

}

}

}
public float VolumeFromDist(float dist, float distMax = 30)
{
Expand Down

0 comments on commit ef49828

Please sign in to comment.