Browse Source

Added some framework stuff for early gameversion detection

pull/32/head
Anairkoen Schno 5 years ago
parent
commit
32d7ff2b7d
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\BackupUnit.cs" />
<Compile Include="Bootstrapper.cs" />
<Compile Include="GameVersionEarly.cs" />
<Compile Include="Injector.cs" />
<Compile Include="PermissionFix.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.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using UnityEngine;
using static IPA.Logging.Logger;
@ -59,12 +60,16 @@ namespace IPA.Injector
loader.Debug("Prepping bootstrapper");
// updates backup
InstallBootstrapPatch();
Updates.InstallPendingUpdates();
LibLoader.SetupAssemblyFilenames(true);
// causes mono to hate itself
//GameVersionEarly.Load();
pluginAsyncLoadTask = PluginLoader.LoadTask();
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(() =>
{
LoadMetadata();
Resolve();
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>
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>
/// The different types of releases of the game.
/// </summary>


+ 26
- 3
appveyor.yml View File

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


Loading…
Cancel
Save