Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/BepInEx/BepInEx
Browse files Browse the repository at this point in the history
  • Loading branch information
ManlyMarco committed Dec 23, 2019
2 parents de6c2cc + b4d5ee5 commit c367fb6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
14 changes: 7 additions & 7 deletions BUILDING.md
Expand Up @@ -10,17 +10,17 @@ You can use the included [cakebuild](https://cakebuild.net/) script that allows

### Windows (Command Line)

Clone or [download](https://github.com/BepInEx/BepInEx/archive/master.zip) this repository.
After that, run
Clone this repository via `git clone https://github.com/BepInEx/BepInEx.git`.
After that, run in the repository directory

```bat
build.bat -target=Build
```

### Windows (PowerShell)

Clone or [download](https://github.com/BepInEx/BepInEx/archive/master.zip) this repository.
After that, run
Clone this repository via `git clone https://github.com/BepInEx/BepInEx.git`.
After that, run in the repository directory

```ps
./build.ps1 -target=Build
Expand All @@ -30,8 +30,8 @@ Make sure you have the execution policy set to enable running scripts.

### Linux (Bash)

Clone or [download](https://github.com/BepInEx/BepInEx/archive/master.zip) this repository.
After that, run
Clone this repository via `git clone https://github.com/BepInEx/BepInEx.git`.
After that, run in the repository directory

```sh
./build.sh --target=Build
Expand All @@ -49,4 +49,4 @@ The build script provides the following build targets (that you can pass via the

## MSBuild

Download and IDE (for example Visual Studio), open the solution file and build it.
Download and IDE (for example Visual Studio), open the solution file and build it.
21 changes: 20 additions & 1 deletion BepInEx/Bootstrap/Chainloader.cs
Expand Up @@ -172,13 +172,16 @@ public static PluginInfo ToPluginInfo(TypeDefinition type)
var dependencies = BepInDependency.FromCecilType(type);
var incompatibilities = BepInIncompatibility.FromCecilType(type);

var bepinVersion = type.Module.AssemblyReferences.FirstOrDefault(reference => reference.Name == "BepInEx")?.Version ?? new Version();

return new PluginInfo
{
Metadata = metadata,
Processes = filters,
Dependencies = dependencies,
Incompatibilities = incompatibilities,
TypeName = type.FullName
TypeName = type.FullName,
TargettedBepInExVersion = bepinVersion
};
}

Expand All @@ -195,6 +198,16 @@ private static bool HasBepinPlugins(AssemblyDefinition ass)
return true;
}

private static bool PluginTargetsWrongBepin(PluginInfo pluginInfo)
{
var pluginTarget = pluginInfo.TargettedBepInExVersion;
// X.X.X.x - compare normally. x.x.x.X - nightly build number, ignore
if (pluginTarget.Major != CurrentAssemblyVersion.Major) return true;
if (pluginTarget.Minor > CurrentAssemblyVersion.Minor) return true;
if (pluginTarget.Minor < CurrentAssemblyVersion.Minor) return false;
return pluginTarget.Build > CurrentAssemblyVersion.Build;
}

/// <summary>
/// The entrypoint for the BepInEx plugin system.
/// </summary>
Expand Down Expand Up @@ -276,6 +289,12 @@ public static void Start()
DependencyErrors.Add(message);
Logger.LogError(message);
}
else if (PluginTargetsWrongBepin(pluginInfo))
{
string message = $@"Plugin [{pluginInfo.Metadata.Name}] targets a wrong version of BepInEx ({pluginInfo.TargettedBepInExVersion}) and might not work until you update";
DependencyErrors.Add(message);
Logger.LogWarning(message);
}
}

var emptyDependencies = new string[0];
Expand Down
9 changes: 8 additions & 1 deletion BepInEx/Contract/PluginInfo.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using BepInEx.Bootstrap;
Expand All @@ -21,6 +22,8 @@ public class PluginInfo : ICacheable

internal string TypeName { get; set; }

internal Version TargettedBepInExVersion { get; set; }

void ICacheable.Save(BinaryWriter bw)
{
bw.Write(TypeName);
Expand All @@ -43,6 +46,8 @@ void ICacheable.Save(BinaryWriter bw)
bw.Write(incList.Count);
foreach (var bepInIncompatibility in incList)
((ICacheable)bepInIncompatibility).Save(bw);

bw.Write(TargettedBepInExVersion.ToString(4));
}

void ICacheable.Load(BinaryReader br)
Expand Down Expand Up @@ -78,6 +83,8 @@ void ICacheable.Load(BinaryReader br)
}

Incompatibilities = incList;

TargettedBepInExVersion = new Version(br.ReadString());
}
}
}

0 comments on commit c367fb6

Please sign in to comment.