Skip to content

Commit

Permalink
Guard against stupid inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
erri120 committed Aug 15, 2023
1 parent 5871202 commit c03e3af
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Games/NexusMods.Games.FOMOD/CoreDelegates/UiDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,16 @@ public void ReportError(

public void UpdateState(FomodInstaller.Interface.ui.InstallerStep[] installSteps, int currentStepId)
{
// NOTE (erri120): The FOMOD library we're using can send us stupid inputs.
if (currentStepId < 0 || currentStepId >= installSteps.Length) return;

// NOTE (erri120): The FOMOD library we're using was designed for threading in JavaScript.
// A semaphore is required because the library can spawn multiple tasks on different threads
// that will call this method multiple times. This can lead to double-state and it's
// just a complete mess. This is what you get when you write a .NET library for JavaScript...
using var waiter = _semaphoreSlim.CustomWait(TimeSpan.Zero);
if (!waiter.HasEntered) return;

Debug.Assert(currentStepId >= 0 && currentStepId < installSteps.Length);

var groupIdMappings = new List<KeyValuePair<int, GroupId>>();
var optionIdMappings = new List<KeyValuePair<int, OptionId>>();

Expand Down

0 comments on commit c03e3af

Please sign in to comment.