Skip to content

Commit

Permalink
LocalProgression: Fix premature completion bug
Browse files Browse the repository at this point in the history
  • Loading branch information
AuriRex committed Mar 3, 2023
1 parent 72634c8 commit 810926d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
19 changes: 17 additions & 2 deletions TheArchive.IL2CPP/Managers/LocalVanityItemManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public void Init()

public void OnExpeditionCompleted(ExpeditionCompletionData data)
{
if (!data.Success)
return;

CheckFirstTimeExpeditionCompletion(data);
CheckTotalUniqueCompletionsRequirementMet(data);
}
Expand All @@ -65,9 +68,21 @@ public void CheckTotalUniqueCompletionsRequirementMet(ExpeditionCompletionData d
return;
}

var vanityItemLayerDropDataBlockPersistentID = RundownDataBlock.GetBlock(data.RundownId).VanityItemLayerDropDataBlock;
var vanityItemLayerDropDataBlockPersistentID = RundownDataBlock.GetBlock(data.RundownId)?.VanityItemLayerDropDataBlock;

if (!vanityItemLayerDropDataBlockPersistentID.HasValue)
{
Logger.Error($"[{nameof(CheckTotalUniqueCompletionsRequirementMet)}] {nameof(vanityItemLayerDropDataBlockPersistentID)} has no value!");
return;
}

VanityItemsLayerDropsDataBlock vilddb = VanityItemsLayerDropsDataBlock.GetBlock(vanityItemLayerDropDataBlockPersistentID);
VanityItemsLayerDropsDataBlock vilddb = VanityItemsLayerDropsDataBlock.GetBlock(vanityItemLayerDropDataBlockPersistentID.Value);

if (vilddb == null)
{
Logger.Error($"[{nameof(CheckTotalUniqueCompletionsRequirementMet)}] {nameof(VanityItemsLayerDropsDataBlock)} with persistent ID {vanityItemLayerDropDataBlockPersistentID} could not be found!");
return;
}

bool anyDropped = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace TheArchive.Models.Progression
{
public struct ExpeditionCompletionData
{
public bool Success => RawSessionData.ExpeditionSurvived;
public string RundownIdString => RawSessionData.RundownId;
public uint RundownId { get; internal set; }
public string ExpeditionId => RawSessionData.ExpeditionId;
Expand Down
10 changes: 8 additions & 2 deletions TheArchive.IL2CPP/Models/Progression/LocalRundownProgression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal bool AddSessionResults(ExpeditionSession session, out ExpeditionComplet
return false;
}

if (Expeditions == null) Expeditions = new Dictionary<string, Expedition>();
Expeditions ??= new Dictionary<string, Expedition>();

Expedition expeditionEntry = GetOrAdd(Expeditions, session.ExpeditionId);

Expand All @@ -48,12 +48,18 @@ internal bool AddSessionResults(ExpeditionSession session, out ExpeditionComplet
Layers layer = stateKvp.Key;
LayerState state = stateKvp.Value;

if(!session.ExpeditionSurvived && state == LayerState.Completed)
{
// If expedition was failed, do not award completion
state = LayerState.Entered;
}

Expedition.Layer expeditionLayer = expeditionEntry.Layers.GetOrAddLayer(layer);

expeditionLayer.IncreaseStateAndCompletion(state);
}

if (session.PrisonerEfficiencyCompleted)
if (session.ExpeditionSurvived && session.PrisonerEfficiencyCompleted)
{
expeditionEntry.AllLayerCompletionCount++;
}
Expand Down

0 comments on commit 810926d

Please sign in to comment.