Skip to content
This repository has been archived by the owner on Aug 7, 2022. It is now read-only.

Commit

Permalink
Implemented RegisterBSA
Browse files Browse the repository at this point in the history
  • Loading branch information
erri120 committed Nov 28, 2019
1 parent c26ba28 commit 4c068c9
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions OMODFramework/Scripting/OBMMScriptHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,10 @@ internal static ScriptReturnData Execute(string inputScript, string dataPath, st
FunctionModifyInstallFolder(line, true);
break;
case "RegisterBSA":
//TODO: FunctionRegisterBSA(line, true);
FunctionRegisterBSA(line, true);
break;
case "UnregisterBSA":
//TODO: FunctionRegisterBSA(line, false);
FunctionRegisterBSA(line, false);
break;
case "FatalError":
srd.CancelInstall = true;
Expand Down Expand Up @@ -2309,5 +2309,31 @@ private static void FunctionDisplayFile(IReadOnlyCollection<string> line, bool i
_scriptFunctions.DisplayText(text, title);
}
}

private static void FunctionRegisterBSA(IReadOnlyCollection<string> line, bool register)
{
var funcName = register ? "Register" : "Unregister";
funcName += "BSA";

if (line.Count == 1)
{
Warn($"Missing arguments for '{funcName}'");
return;
}

var esp = line.ElementAt(1).ToLower();
if (esp.Contains(",") || esp.Contains(";") || esp.Contains("="))
{
Warn($"Invalid argument for '{funcName}'\nBSA file names are not allowed to include the characters ',' '=' or ';'");
return;
}

if(line.Count > 2) Warn($"Unexpected arguments after '{funcName}'");

if (register && !srd.RegisterBSASet.Contains(esp))
srd.RegisterBSASet.Add(esp);
else
srd.RegisterBSASet.RemoveWhere(s => s == esp);
}
}
}

0 comments on commit 4c068c9

Please sign in to comment.