Skip to content

Commit

Permalink
Update to 2021.12.14
Browse files Browse the repository at this point in the history
UseDtls parameter was added to region file
  • Loading branch information
miniduikboot committed Dec 15, 2021
1 parent 9098636 commit 476c1a1
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 5 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI

on: ["push", "pull_request"]

jobs:
build:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
with:
submodules: true

- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.x

- name: Build
run: build.sh

- uses: actions/upload-artifact@v2
with:
name: Mini.RegionInstall.dll
path: output/Mini.RegionInstall.dll

- uses: actions/upload-artifact@v2
with:
name: Mini.RegionInstall-NoReactor.dll
path: output/Mini.RegionInstall-NoReactor.dll
2 changes: 1 addition & 1 deletion Mini.RegionInstall/Mini.RegionInstall.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<PropertyGroup>
<GamePlatform Condition="'$(GamePlatform)' == ''">Steam</GamePlatform>
<GameVersion>2021.11.9</GameVersion>
<GameVersion>2021.12.14</GameVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
15 changes: 11 additions & 4 deletions Mini.RegionInstall/RegionInfoConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ internal class RegionInfoConverter : JsonConverter<IRegionInfo>

Dictionary<string, string> stringValues = new Dictionary<string, string>();
Dictionary<string, ushort> intValues = new Dictionary<string, ushort>();
Dictionary<string, bool> boolValues = new Dictionary<string, bool>();

while (reader.Read())
{
if (reader.TokenType == JsonTokenType.EndObject)
{
return Assemble(stringValues, intValues);
return Assemble(stringValues, intValues, boolValues);
}
else if (reader.TokenType == JsonTokenType.PropertyName)
{
Expand All @@ -58,6 +59,11 @@ internal class RegionInfoConverter : JsonConverter<IRegionInfo>
ushort val = reader.GetUInt16();
intValues.Add(propName, val);
}
else if (propName == "UseDtls")
{
bool val = reader.GetBoolean();
boolValues.Add(propName, val);
}
else if (propName != null)
{
string? val = reader.GetString();
Expand All @@ -82,7 +88,7 @@ public override void Write(Utf8JsonWriter writer, IRegionInfo value, JsonSeriali
throw new NotImplementedException();
}

private static IRegionInfo? Assemble(Dictionary<string, string> stringValues, Dictionary<string, ushort> intValues)
private static IRegionInfo? Assemble(Dictionary<string, string> stringValues, Dictionary<string, ushort> intValues, Dictionary<string, bool> boolValues)
{
if (!stringValues.TryGetValue("$type", out string type))
{
Expand All @@ -97,10 +103,11 @@ public override void Write(Utf8JsonWriter writer, IRegionInfo value, JsonSeriali
stringValues.TryGetValue("Name", out string? name);
intValues.TryGetValue("Port", out ushort port);
intValues.TryGetValue("TranslateName", out ushort translateName);
boolValues.TryGetValue("UseDtls", out bool useDtls); // Defaults to false

// HACK: Unhollower is unable to deal with inheritance properly, so you need special code to deal with it.
// Simplify when https://github.com/knah/Il2CppAssemblyUnhollower/issues/33 is resolved.
return new DnsRegionInfo(fqdn, name, (StringNames)translateName, defaultIp, port).Duplicate();
return new DnsRegionInfo(fqdn, name, (StringNames)translateName, defaultIp, port, useDtls).Duplicate();

case "StaticRegionInfo, Assembly-CSharp":
// TODO implement
Expand All @@ -112,7 +119,7 @@ public override void Write(Utf8JsonWriter writer, IRegionInfo value, JsonSeriali

private static IRegionInfo? AddLocalhost()
{
return new DnsRegionInfo("localhost", "Localhost", StringNames.NoTranslation, "127.0.0.1", 22023).Cast<IRegionInfo>();
return new DnsRegionInfo("localhost", "Localhost", StringNames.NoTranslation, "127.0.0.1", 22023, false).Cast<IRegionInfo>();
}
}
}
7 changes: 7 additions & 0 deletions nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>

<configuration>
<packageSources>
<add key="BepInEx" value="https://nuget.bepinex.dev/v3/index.json" />
</packageSources>
</configuration>

0 comments on commit 476c1a1

Please sign in to comment.