-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
54 lines (42 loc) · 1.29 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.Collections.Generic;
using System.IO;
using Gibbed.RED4.ScriptFormats;
using Gibbed.RED4.ScriptFormats.Emit;
namespace RED4CGTest
{
internal static partial class Program
{
static readonly List<Action> Patches = new List<Action>
{
AddAllRecipes,
MakeOP,
};
static CacheFile cache;
static CodeGenerator cg;
public static void Main(string[] args)
{
if (args[0].Length == 0)
throw new ArgumentException("You must provide a final.redscripts file!");
byte[] fileBytes = File.ReadAllBytes(args[0]);
using MemoryStream input = new MemoryStream(fileBytes, false);
using MemoryStream output = new MemoryStream();
cache = CacheFile.Load(input, false);
cg = new CodeGenerator();
CreateNatives();
CreateFunctions();
ApplyPatches();
cache.Save(output);
output.Flush();
File.WriteAllBytes("output.redscripts", output.ToArray());
}
static void ApplyPatches()
{
foreach (Action func in Patches)
{
func.Invoke();
cg.Reset();
}
}
}
}