Skip to content

Commit

Permalink
Merge pull request #19 from Secre-C/main
Browse files Browse the repository at this point in the history
allow new flow functions to be added to library overrides
  • Loading branch information
Sewer56 authored Apr 30, 2024
2 parents 35760ae + 1e52c9f commit 72a4131
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions Emulator/BF.File.Emulator/Bf/BfBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,27 @@ private Library OverrideLibraries(Library library)
// Override existing functions
foreach (var func in _libraryFuncs)
{
int module = -1;
int index = -1;

for (int i = 0; i < library.FlowScriptModules.Count; i++)
{
var existing = library.FlowScriptModules[i].Functions.FindIndex(x => x.Index == func.Index);
if (existing != -1)
library.FlowScriptModules[i].Functions[existing] = func;
index = library.FlowScriptModules[i].Functions.FindIndex(x => x.Index == func.Index);

if (index != -1)
{
module = i;
break;
}
}

if (module != -1 && index != -1)
{
library.FlowScriptModules[module].Functions[index] = func;
}
else
{
library.FlowScriptModules.Last().Functions.Add(func);
}
}

Expand Down

0 comments on commit 72a4131

Please sign in to comment.