Browse Source

Added some framework stuff for early gameversion detection

pull/46/head
Anairkoen Schno 5 years ago
parent
commit
f153df4630
7 changed files with 97 additions and 4 deletions
  1. +1
    -1
      Doorstop
  2. +48
    -0
      IPA.Injector/GameVersionEarly.cs
  3. +1
    -0
      IPA.Injector/IPA.Injector.csproj
  4. +5
    -0
      IPA.Injector/Injector.cs
  5. +1
    -0
      IPA.Loader/Loader/PluginLoader.cs
  6. +15
    -0
      IPA.Loader/Utilities/BeatSaber.cs
  7. +26
    -3
      appveyor.yml

+ 1
- 1
Doorstop

@ -1 +1 @@
Subproject commit 17449269e7c39a652cad597396540fd6e9663bab
Subproject commit 02647aa40bdde4e5027eb596082a6787497b92e9

+ 48
- 0
IPA.Injector/GameVersionEarly.cs View File

@ -0,0 +1,48 @@
using IPA.Utilities;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace IPA.Injector
{
internal static class GameVersionEarly
{
private static string ResolveDataPath(string installDir) =>
Path.Combine(Directory.EnumerateDirectories(installDir, "*_Data").First(), "globalgamemanagers");
internal static string GetGameVersion()
{
var mgr = ResolveDataPath(BeatSaber.InstallPath);
using (var stream = File.OpenRead(mgr))
using (var reader = new BinaryReader(stream, Encoding.UTF8))
{
const string key = "public.app-category.games";
int pos = 0;
while (stream.Position < stream.Length && pos < key.Length)
{
if (reader.ReadByte() == key[pos]) pos++;
else pos = 0;
}
if (stream.Position == stream.Length) // we went through the entire stream without finding the key
throw new KeyNotFoundException("Could not find key '" + key + "' in " + mgr);
// otherwise pos == key.Length, which means we found it
int offset = 136 - key.Length - sizeof(int);
stream.Seek(offset, SeekOrigin.Current); // advance past junk to beginning of string
int strlen = reader.ReadInt32(); // assumes LE
var strbytes = reader.ReadBytes(strlen);
return Encoding.UTF8.GetString(strbytes);
}
}
internal static SemVer.Version SafeParseVersion() => new SemVer.Version(GetGameVersion(), true);
internal static void Load() => BeatSaber.SetEarlyGameVersion(SafeParseVersion());
}
}

+ 1
- 0
IPA.Injector/IPA.Injector.csproj View File

@ -55,6 +55,7 @@
<Compile Include="Backups\BackupManager.cs" /> <Compile Include="Backups\BackupManager.cs" />
<Compile Include="Backups\BackupUnit.cs" /> <Compile Include="Backups\BackupUnit.cs" />
<Compile Include="Bootstrapper.cs" /> <Compile Include="Bootstrapper.cs" />
<Compile Include="GameVersionEarly.cs" />
<Compile Include="Injector.cs" /> <Compile Include="Injector.cs" />
<Compile Include="PermissionFix.cs" /> <Compile Include="PermissionFix.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />


+ 5
- 0
IPA.Injector/Injector.cs View File

@ -8,6 +8,7 @@ using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using UnityEngine; using UnityEngine;
using static IPA.Logging.Logger; using static IPA.Logging.Logger;
@ -59,12 +60,16 @@ namespace IPA.Injector
loader.Debug("Prepping bootstrapper"); loader.Debug("Prepping bootstrapper");
// updates backup
InstallBootstrapPatch(); InstallBootstrapPatch();
Updates.InstallPendingUpdates(); Updates.InstallPendingUpdates();
LibLoader.SetupAssemblyFilenames(true); LibLoader.SetupAssemblyFilenames(true);
// causes mono to hate itself
//GameVersionEarly.Load();
pluginAsyncLoadTask = PluginLoader.LoadTask(); pluginAsyncLoadTask = PluginLoader.LoadTask();
permissionFixTask = PermissionFix.FixPermissions(new DirectoryInfo(Environment.CurrentDirectory)); permissionFixTask = PermissionFix.FixPermissions(new DirectoryInfo(Environment.CurrentDirectory));
} }


+ 1
- 0
IPA.Loader/Loader/PluginLoader.cs View File

@ -21,6 +21,7 @@ namespace IPA.Loader
{ {
internal static Task LoadTask() => Task.Run(() => internal static Task LoadTask() => Task.Run(() =>
{ {
LoadMetadata(); LoadMetadata();
Resolve(); Resolve();
ComputeLoadOrder(); ComputeLoadOrder();


+ 15
- 0
IPA.Loader/Utilities/BeatSaber.cs View File

@ -18,6 +18,21 @@ namespace IPA.Utilities
/// <value>the SemVer version of the game</value> /// <value>the SemVer version of the game</value>
public static Version GameVersion => _gameVersion ?? (_gameVersion = new Version(Application.version, true)); public static Version GameVersion => _gameVersion ?? (_gameVersion = new Version(Application.version, true));
internal static void SetEarlyGameVersion(Version ver)
{
_gameVersion = ver;
Logging.Logger.log.Debug($"GameVersion set early to {ver}");
}
internal static void EnsureRuntimeGameVersion()
{
var rtVer = new Version(Application.version, true);
if (rtVer != _gameVersion)
{
Logging.Logger.log.Warn($"Early version {_gameVersion} parsed from game files doesn't match runtime version {rtVer}!");
_gameVersion = rtVer;
}
}
/// <summary> /// <summary>
/// The different types of releases of the game. /// The different types of releases of the game.
/// </summary> /// </summary>


+ 26
- 3
appveyor.yml View File

@ -1,10 +1,14 @@
version: 'BSIPA-{branch}-{build}' version: 'BSIPA-{branch}-{build}'
environment: environment:
bsipa_version: '3.12.23' bsipa_version: '3.12.23'
gh_token: gh_token:
secure: E42gl/yepETuoLSwbJZ1GmEIPK6cCJu6zkd59NA21XiICtEV6COOLW7aehi1tcVU secure: E42gl/yepETuoLSwbJZ1GmEIPK6cCJu6zkd59NA21XiICtEV6COOLW7aehi1tcVU
BUILD_DOCS: 'no'
pull_requests: pull_requests:
do_not_increment_build_number: true do_not_increment_build_number: true
install: install:
- git submodule update --init --recursive - git submodule update --init --recursive
- nuget restore - nuget restore
@ -14,26 +18,43 @@ install:
#git checkout $env:APPVEYOR_REPO_BRANCH -q #git checkout $env:APPVEYOR_REPO_BRANCH -q
choco install docfx -y choco install docfx -y
} }
image: Visual Studio 2019 Preview
image: Visual Studio 2019
configuration: configuration:
- Release - Release
platform: platform:
- x86
- x64 - x64
#- x86
for:
-
matrix:
only:
- configuration: Release
platform: x64
environment:
BUILD_DOCS: 'yes'
branches: branches:
except: except:
- gh-pages - gh-pages
cache: cache:
- '%LocalAppData%\NuGet\v3-cache' # NuGet v3 - '%LocalAppData%\NuGet\v3-cache' # NuGet v3
artifacts: artifacts:
- path: IPA/bin/$(configuration) - path: IPA/bin/$(configuration)
name: BSIPA name: BSIPA
- path: BSIPA-ModList/bin/$(configuration) - path: BSIPA-ModList/bin/$(configuration)
name: ModList name: ModList
build: build:
verbosity: normal verbosity: normal
project: BSIPA.sln project: BSIPA.sln
skip_tags: false skip_tags: false
deploy: deploy:
- provider: GitHub - provider: GitHub
release: BSIPA $(bsipa_version)-draft release: BSIPA $(bsipa_version)-draft
@ -51,6 +72,7 @@ deploy:
on: on:
branch: master branch: master
APPVEYOR_REPO_TAG: false APPVEYOR_REPO_TAG: false
- provider: GitHub - provider: GitHub
release: -ignore- release: -ignore-
tag: create_tag tag: create_tag
@ -63,9 +85,10 @@ deploy:
on: on:
branch: master branch: master
APPVEYOR_REPO_TAG: true APPVEYOR_REPO_TAG: true
before_deploy: before_deploy:
- ps: | - ps: |
if ($env:APPVEYOR_REPO_BRANCH -eq 'master')
if ($env:APPVEYOR_REPO_BRANCH -eq 'master' -and $env:BUILD_DOCS -eq 'yes')
{ {
cd docs cd docs


Loading…
Cancel
Save