Skip to content

Commit

Permalink
no longer necessary to persist MobSpawnEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
SlashNephy committed Jul 8, 2024
1 parent 80e4650 commit c4117b6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
1 change: 0 additions & 1 deletion FaloopIntegration/Config/PluginConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class PluginConfig : IPluginConfiguration

public PerRankConfig Fate = new();

public List<MobSpawnEvent> SpawnStates = [];
public bool EnableActiveMobUi;
public bool HideActiveMobUiInDuty;
public bool EnableSimpleReports;
Expand Down
19 changes: 5 additions & 14 deletions FaloopIntegration/FaloopIntegration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public sealed class FaloopIntegration : DivinationPlugin<FaloopIntegration, Plug
private World? currentWorld;
private World? homeWorld;
public PluginStatus Status;
private List<MobSpawnEvent> spawnEvents = [];

public FaloopIntegration(IDalamudPluginInterface pluginInterface) : base(pluginInterface)
{
Expand Down Expand Up @@ -61,7 +62,6 @@ public FaloopIntegration(IDalamudPluginInterface pluginInterface) : base(pluginI
Dalamud.PluginInterface.UiBuilder.Draw += Ui.Draw;

Connect();
CleanSpawnHistories();
}

private void OnLogin()
Expand Down Expand Up @@ -166,7 +166,7 @@ private void OnMobReport(MobReportData data)
}
}

var previous = Config.SpawnStates.FirstOrDefault(x =>
var previous = spawnEvents.FirstOrDefault(x =>
x.MobId == mobData.BNpcId &&
x.WorldId == worldId &&
x.ZoneInstance == data.Ids.ZoneInstance);
Expand Down Expand Up @@ -241,8 +241,7 @@ private void OnMobSpawn(MobSpawnEvent ev, int channel)
{
Ui.OnMobSpawn(ev);

Config.SpawnStates.Add(ev);
Dalamud.PluginInterface.SavePluginConfig(Config);
spawnEvents.Add(ev);

var payloads = new List<Payload>();
if (Config.EnableSimpleReports)
Expand Down Expand Up @@ -286,20 +285,18 @@ private void OnMobFalseSpawn(MobDeathEvent ev)
{
Ui.OnMobDeath(ev);

Config.SpawnStates.RemoveAll(x => x.Id == ev.Id);
Dalamud.PluginInterface.SavePluginConfig(Config);
spawnEvents.RemoveAll(x => x.Id == ev.Id);
}

private void OnMobDeath(MobDeathEvent ev, int channel, bool skipOrphanReport)
{
Ui.OnMobDeath(ev);

if (skipOrphanReport && Config.SpawnStates.RemoveAll(x => x.Id == ev.Id) == 0)
if (skipOrphanReport && spawnEvents.RemoveAll(x => x.Id == ev.Id) == 0)
{
DalamudLog.Log.Debug("OnDeathMobReport: skipOrphanReport");
return;
}
Dalamud.PluginInterface.SavePluginConfig(Config);

var payloads = new List<Payload>();
if (Config.EnableSimpleReports)
Expand Down Expand Up @@ -410,12 +407,6 @@ public void EmitMockData()
});
}

private void CleanSpawnHistories()
{
Config.SpawnStates.RemoveAll(x => DateTime.UtcNow - x.SpawnedAt > TimeSpan.FromHours(1));
Dalamud.PluginInterface.SavePluginConfig(Config);
}

protected override void ReleaseManaged()
{
Dalamud.PluginInterface.SavePluginConfig(Config);
Expand Down

0 comments on commit c4117b6

Please sign in to comment.