Skip to content
This repository has been archived by the owner on Jul 26, 2021. It is now read-only.

Commit

Permalink
Use GameVersion property
Browse files Browse the repository at this point in the history
  • Loading branch information
js6pak committed Jan 3, 2021
1 parent 346cf1b commit c634a5a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
7 changes: 4 additions & 3 deletions Reactor.OxygenFilter.MSBuild/LoadMappings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ namespace Reactor.OxygenFilter.MSBuild
{
public class LoadMappings : Task
{
public string TargetGamePlatform { get; set; } = "Steam";
[Required]
public string GameVersion { get; set; }

[Required]
public string Mappings { get; set; }
Expand All @@ -30,7 +31,7 @@ public override bool Execute()

var directory = Path.Combine(Context.TempPath, repo.Replace("/", "_"), version);
Directory.CreateDirectory(directory);
var file = Path.Combine(directory, $"{TargetGamePlatform.ToLower()}.json");
var file = Path.Combine(directory, $"{GameVersion}.json");

if (File.Exists(file))
{
Expand All @@ -39,7 +40,7 @@ public override bool Execute()
}

var httpClient = new HttpClient();
var json = httpClient.GetStringAsync($"https://github.com/{repo}/releases/download/{version}/{TargetGamePlatform.ToLower()}.json").GetAwaiter().GetResult();
var json = httpClient.GetStringAsync($"https://github.com/{repo}/releases/download/{version}/{GameVersion}.json").GetAwaiter().GetResult();

MappingsJson = json;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</Target>

<Target Name="LoadMappings">
<LoadMappings TargetGamePlatform="$(TargetGamePlatform)" Mappings="$(Mappings)">
<LoadMappings GameVersion="$(GameVersion)" Mappings="$(Mappings)">
<Output TaskParameter="MappingsJson" PropertyName="MappingsJson" />
</LoadMappings>
</Target>
Expand Down Expand Up @@ -48,6 +48,6 @@
</Target>

<Target Name="Reobfuscate" AfterTargets="Build">
<Reobfuscate AmongUs="$(AmongUs)" Input="$(ProjectDir)$(OutputPath)$(AssemblyName).dll" ReferencedAssemblies="@(ReferencePath)" />
<Reobfuscate GameVersion="$(GameVersion)" AmongUs="$(AmongUs)" Input="$(ProjectDir)$(OutputPath)$(AssemblyName).dll" ReferencedAssemblies="@(ReferencePath)" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<LangVersion>latest</LangVersion>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

<Version>0.1.5</Version>
<Version>0.2.0</Version>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/NuclearPowered/Reactor.OxygenFilter</RepositoryUrl>
<PackageLicenseExpression>LGPL-3.0-or-later</PackageLicenseExpression>
Expand Down
18 changes: 9 additions & 9 deletions Reactor.OxygenFilter.MSBuild/Reobfuscate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ namespace Reactor.OxygenFilter.MSBuild
{
public class Reobfuscate : Task
{
[Required]
public string GameVersion { get; set; }

[Required]
public string AmongUs { get; set; }

Expand All @@ -35,18 +38,15 @@ public override bool Execute()

var obfuscatedAssembly = AssemblyDefinition.ReadAssembly(Path.Combine(AmongUs, "BepInEx", "unhollowed", "Assembly-CSharp.dll"));

var referencedAssemblies = ReferencedAssemblies.Select(AssemblyDefinition.ReadAssembly).ToArray();

resolver.ResolveFailure += (_, reference) =>
{
foreach (var referencedAssembly in ReferencedAssemblies)
foreach (var referencedAssembly in referencedAssemblies)
{
if (Path.GetFileNameWithoutExtension(referencedAssembly) == reference.Name)
if (referencedAssembly.Name.FullName == reference.FullName)
{
var assemblyDefinition = AssemblyDefinition.ReadAssembly(referencedAssembly);

if (assemblyDefinition.Name.FullName == reference.FullName)
{
return assemblyDefinition;
}
return referencedAssembly;
}
}

Expand Down Expand Up @@ -258,7 +258,7 @@ public override bool Execute()

var outputDirectory = Path.Combine(Path.GetDirectoryName(Input), "reobfuscated");
Directory.CreateDirectory(outputDirectory);
moduleDefinition.Write(Path.Combine(outputDirectory, Path.GetFileName(Input)));
moduleDefinition.Write(Path.Combine(outputDirectory, Path.GetFileNameWithoutExtension(Input) + $"-{GameVersion}.dll"));

return true;
}
Expand Down

0 comments on commit c634a5a

Please sign in to comment.