Skip to content

Commit

Permalink
v1.1.0 (#3)
Browse files Browse the repository at this point in the history
Check the pull request for change logs.
  • Loading branch information
TIRTAGT authored Feb 21, 2024
1 parent aa62709 commit 22689ab
Show file tree
Hide file tree
Showing 20 changed files with 683 additions and 267 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,17 @@ Dates are in the format of `YYYY-MM-DD` (Year-Month-Day).

----

## [1.1.0] - 2024-02-21
- IPv6 hosting and join support
- AAAA DNS Record support for IPv6, SRV support for IPv4 and IPv6 (Adjustable Priority in config)
- Fix invisible join settings window after accidentally clicking host weekly challange
- Fix LatencyRPC timing issues, add alternate latency source
- Fix wrong NetworkManager instance check
- Migrate to .NET Standard 2.1
- Avoid SocketTImeout crash
- Fix HideJoinData doesn't protect config leak
- Add option to disable Latency HUD when hosting
- Use Late Inject to further guard messing up Online mode

## [1.0.0] - 2024-02-09
- Initial release
3 changes: 2 additions & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ Thank you all for your contributions!

----

- [Matthew Tirtawidjaja](https://github.com/TIRTAGT) \<matthew@tirtagt.xyz\>
- [Matthew Tirtawidjaja](https://github.com/TIRTAGT) \<matthew@tirtagt.xyz\>
- [CoolLKKPS](https://github.com/CoolLKKPS)
132 changes: 28 additions & 104 deletions LCDirectLAN.csproj
Original file line number Diff line number Diff line change
@@ -1,103 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="packages\BepInEx.AssemblyPublicizer.MSBuild.0.4.1\build\BepInEx.AssemblyPublicizer.MSBuild.props" Condition="Exists('packages\BepInEx.AssemblyPublicizer.MSBuild.0.4.1\build\BepInEx.AssemblyPublicizer.MSBuild.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8551A54F-0C5C-48D0-ACF2-1C91581CD69D}</ProjectGuid>
<TargetFramework>netstandard2.1</TargetFramework>
<SignAssembly>False</SignAssembly>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LCDirectLAN</RootNamespace>
<AssemblyName>LCDirectLAN</AssemblyName>
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DnsClient" Version="1.7.0" />
</ItemGroup>

<ItemGroup>
<Reference Include="0Harmony">
<Private>False</Private>
</Reference>
<Reference Include="AsmResolver, Version=5.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\BepInEx.AssemblyPublicizer.MSBuild.0.4.1\lib\net472\AsmResolver.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="AsmResolver.DotNet, Version=5.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\BepInEx.AssemblyPublicizer.MSBuild.0.4.1\lib\net472\AsmResolver.DotNet.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="AsmResolver.PE, Version=5.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\BepInEx.AssemblyPublicizer.MSBuild.0.4.1\lib\net472\AsmResolver.PE.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="AsmResolver.PE.File, Version=5.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\BepInEx.AssemblyPublicizer.MSBuild.0.4.1\lib\net472\AsmResolver.PE.File.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp">
<Publicize>true</Publicize>
<Private>False</Private>
</Reference>
<Reference Include="BepInEx">
<Private>False</Private>
</Reference>
<Reference Include="BepInEx.AssemblyPublicizer, Version=0.4.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\BepInEx.AssemblyPublicizer.MSBuild.0.4.1\lib\net472\BepInEx.AssemblyPublicizer.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="BepInEx.AssemblyPublicizer.MSBuild, Version=0.4.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\BepInEx.AssemblyPublicizer.MSBuild.0.4.1\lib\net472\BepInEx.AssemblyPublicizer.MSBuild.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="DnsClient, Version=1.7.0.0, Culture=neutral, PublicKeyToken=4574bb5573c51424, processorArchitecture=MSIL">
<HintPath>packages\DnsClient.1.7.0\lib\net471\DnsClient.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Facepunch.Steamworks.Win64, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
<Reference Include="Facepunch.Steamworks.Win64">
<Private>False</Private>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="Unity.Collections, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<Reference Include="Unity.Collections">
<Private>False</Private>
</Reference>
<Reference Include="Unity.Netcode.Runtime, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<Reference Include="Unity.Netcode.Runtime">
<Private>False</Private>
</Reference>
<Reference Include="Unity.TextMeshPro, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<Reference Include="Unity.TextMeshPro">
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine">
Expand All @@ -106,51 +61,20 @@
<Reference Include="UnityEngine.CoreModule">
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<Reference Include="UnityEngine.UI">
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="LCDirectLan.cs" />
<Compile Include="Patches\CustomUsername\StartOfRoundPatch.cs" />
<Compile Include="Patches\CustomUsername\UsernameRPC.cs" />
<Compile Include="Patches\ConfigurableLAN\MenuManagerPatch.cs" />
<Compile Include="Patches\CustomUsername\PlayerControllerBPatch.cs" />
<Compile Include="Patches\LatencyHUD\HUDManagerPatch.cs" />
<Compile Include="Patches\LatencyHUD\LatencyRPC.cs" />
<Compile Include="Patches\PreInitSceneScriptPatch.cs" />
<Compile Include="Patches\UnityNetworking\UnityTransportPatch.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utility\allPlayerScripts.cs" />
<Compile Include="Utility\ResolveDNS.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\BepInEx.AssemblyPublicizer.MSBuild.0.4.1\build\BepInEx.AssemblyPublicizer.MSBuild.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\BepInEx.AssemblyPublicizer.MSBuild.0.4.1\build\BepInEx.AssemblyPublicizer.MSBuild.props'))" />
</Target>
<PropertyGroup>
<PostBuildEvent>xcopy /d /y "$(ProjectDir)packages\DnsClient.1.7.0\lib\net471\DnsClient.dll" "$(TargetDir)libs\DnsClient.1.7.0\"

xcopy /d /y "$(ProjectDir)packages\DnsClient.1.7.0\README.md" "$(TargetDir)libs\DnsClient.1.7.0\"

xcopy /d /y "$(ProjectDir)packages\System.Buffers.4.5.1\LICENSE.TXT" "$(TargetDir)libs\System.Buffers.4.5.1\"
rename "$(TargetDir)libs\System.Buffers.4.5.1\LICENSE.TXT" "LICENSE"

xcopy /d /y "$(ProjectDir)packages\System.Buffers.4.5.1\THIRD-PARTY-NOTICES.TXT" "$(TargetDir)libs\System.Buffers.4.5.1\"
rename "$(TargetDir)libs\System.Buffers.4.5.1\THIRD-PARTY-NOTICES.TXT" "THIRD-PARTY-NOTICES"

xcopy /d /y "$(ProjectDir)packages\System.Buffers.4.5.1\version.txt" "$(TargetDir)libs\System.Buffers.4.5.1\"
rename "$(TargetDir)libs\System.Buffers.4.5.1\version.txt" "version"

xcopy /d /y "$(ProjectDir)packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll" "$(TargetDir)libs\System.Buffers.4.5.1\"</PostBuildEvent>
</PropertyGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Copy SourceFiles="$(ProjectDir)packages\dnsclient\1.7.0\lib\netstandard2.1\DnsClient.dll" DestinationFiles="$(TargetDir)libs\DnsClient.1.7.0\DnsClient.dll" />
<Copy SourceFiles="$(ProjectDir)packages\dnsclient\1.7.0\README.md" DestinationFiles="$(TargetDir)libs\DnsClient.1.7.0\README.md" />

<Copy SourceFiles="$(ProjectDir)packages\system.buffers\4.5.1\LICENSE.TXT" DestinationFiles="$(TargetDir)libs\System.Buffers.4.5.1\LICENSE" />
<Copy SourceFiles="$(ProjectDir)packages\system.buffers\4.5.1\THIRD-PARTY-NOTICES.TXT" DestinationFiles="$(TargetDir)libs\System.Buffers.4.5.1\THIRD-PARTY-NOTICES" />
<Copy SourceFiles="$(ProjectDir)packages\system.buffers\4.5.1\version.txt" DestinationFiles="$(TargetDir)libs\System.Buffers.4.5.1\version" />
<Copy SourceFiles="$(ProjectDir)packages\system.buffers\4.5.1\lib\netstandard2.0\System.Buffers.dll" DestinationFiles="$(TargetDir)libs\System.Buffers.4.5.1\netstandard2.0\System.Buffers.dll" />
</Target>
<Target Name="SpicNSpan" AfterTargets="Clean">
<RemoveDir Directories="$(TargetDir)" />
</Target>
Expand Down
2 changes: 1 addition & 1 deletion LCDirectLAN.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34408.163
VisualStudioVersion = 17.9.34607.119
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LCDirectLAN", "LCDirectLAN.csproj", "{8551A54F-0C5C-48D0-ACF2-1C91581CD69D}"
EndProject
Expand Down
51 changes: 47 additions & 4 deletions LCDirectLan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,30 @@ public class LCDirectLan : BaseUnityPlugin
{
public const string PLUGIN_GUID = "TIRTAGT.LCDirectLAN";
public const string PLUGIN_NAME = "LCDirectLAN";
public const string PLUGIN_VERSION = "0.1";
/// <summary>
/// Version of the plugin that follows semantic versioning format<br/>
///
/// <b>Major</b> - Major version number, incremented when there are significant changes that breaks compatibility<br/>
/// <b>Minor</b> - Minor version number, incremented when there are changes that breaks compatibility<br/>
/// <b>Build</b> - Build number, incremented when there are changes that doesn't break any compatibility<br/>
/// </summary>
public const string PLUGIN_VERSION = "1.1.0";

/// <summary>
/// Version of the plugin assembly that follows "major.minor.build.revision" format<br/>
///
/// <b>Major</b> - Major version number, incremented when there are significant changes that breaks compatibility<br/>
/// <b>Minor</b> - Minor version number, incremented when there are changes that breaks compatibility<br/>
/// <b>Build</b> - Build number, incremented when there are changes that doesn't break any compatibility<br/>
/// <b>Revision</b> - Revision number, 00000 (for Debug/Development) or 10101 (for Release)<br/>
/// </summary>
#if DEBUG
public const string PLUGIN_ASSEMBLY_VERSION = PLUGIN_VERSION + ".00000";
public const string PLUGIN_COMPILE_CONFIG = "Debug";
#else
public const string PLUGIN_ASSEMBLY_VERSION = PLUGIN_VERSION + ".10101";
public const string PLUGIN_COMPILE_CONFIG = "Release";
#endif

private readonly Harmony HarmonyLib = new Harmony(LCDirectLan.PLUGIN_GUID);
private static LCDirectLan Instance;
Expand Down Expand Up @@ -68,8 +91,10 @@ private void Awake()
config.Bind<ushort>("Join", "DefaultPort", 7777, new ConfigDescription("Default Port, change-able in the game"));
config.Bind<bool>("Join", "RememberLastJoinSettings", false, new ConfigDescription("Overwrite the default join configuration values when changed in the game"));
config.Bind<byte>("Join", "HideRawJoinData", 3, new ConfigDescription("Do not display or save the recently joined server data to avoid Server Leak, useful for streamers.\nThis config accepts a bitwise value\nExamples:\n0: Show anything (Disabled/No Hiding)\n1: Hide IP Address\n2. Hide Port Number\n3. Hide IP and Port\n4. Hide Hostname\n7. Hide all of them (IP,Port,Hostname)", new AcceptableValueList<byte>(new byte[] { 0, 1, 2, 3, 4, 7 })));
config.Bind<bool>("Join", "SRVHost_PreferIPv6", false, new ConfigDescription("Prefer IPv6 over IPv4 for SRV Record host lookup when using DNS SRV Record to join"));

/* Default network configuration when hosting LAN lobbies */
config.Bind<bool>("Host", "ListenOnIPv6", false, new ConfigDescription("Should the game listen on IPv6 when hosting instead of IPv4 ?\nDual-Stack Listening is not supported due to the game Unity Transport version."));
config.Bind<ushort>("Host", "DefaultPort", 7777, new ConfigDescription("Default Port for hosting, the default vanilla port is 7777"));

/* Custom Username Feature / Patches */
Expand All @@ -84,15 +109,33 @@ private void Awake()

/* Latency HUD Patches */
config.Bind<bool>("Latency HUD", "Enabled", true, new ConfigDescription("Enable LatencyHUDPatch ?"));
config.Bind<bool>("Latency HUD", "RTTMeasurement", true, new ConfigDescription("Measure Round Trip Time (RTT) instead of one-way latency, this also adds server processing lag to the total latency for more accurate latency representation"));
config.Bind<bool>("Latency HUD", "ServerLagWarning", true, new ConfigDescription("Enable Server Lag Warning ?\nThis will notify the client when the server processing lag is too high"));
config.Bind<bool>("Latency HUD", "DisableCustomLatencyRPC", false, new ConfigDescription($"Disable {LCDirectLan.PLUGIN_NAME}'s custom RPC and replace use UnityTransport's GetCurrentRtt() for measuring latency, additional warning feature will be disabled too"));
config.Bind<bool>("Latency HUD", "HideHUDWhileHosting", true, new ConfigDescription("Hide the Latency HUD when hosting a game, since measuring latency to host (yourself) is not really useful"));
config.Bind<bool>("Latency HUD", "RTTMeasurement", true, new ConfigDescription("Measure Round Trip Time (RTT) instead of one-way latency, which is a more accurate latency representation"));
config.Bind<bool>("Latency HUD", "DisplayWarningOnFailure", true, new ConfigDescription("Display an in-game warning when there is a problem with LatencyHUDPatch functionality"));
config.Bind<float>("Latency HUD", "Offset_X", 0.0F, new ConfigDescription("Adjust the X position of the Latency HUD\nHigher value moves the HUD to the right, lower value moves the HUD to the left"));
config.Bind<float>("Latency HUD", "Offset_Y", 0.0F, new ConfigDescription("Adjust the Y position of the Latency HUD\nHigher value moves the HUD to the top, lower value moves the HUD to the bottom"));
config.Bind<float>("Latency HUD", "TextSize", 13.0F, new ConfigDescription("Adjust font size of the Latency HUD (Minimum: 9)"));

config.Save();

// Inject script to detect if we are started in LAN or Online mode
Patches.PreInitSceneScriptPatch.SetLateInjector(InjectPatches);
HarmonyLib.PatchAll(typeof(Patches.PreInitSceneScriptPatch));

this.Logger.LogInfo($"{LCDirectLan.PLUGIN_NAME} is loaded");
}

/// <summary>
/// A dedicated inject method to apply patches (allows early or late patching behavior)
/// </summary>
private void InjectPatches() {
// Do not inject any further patches if we are not in LAN mode
if (!LCDirectLan.IsOnLanMode) {
this.Logger.LogError($"{LCDirectLan.PLUGIN_NAME} should not be injected when game is started on Online (steam) mode");
return;
}

HarmonyLib.PatchAll(typeof(Patches.ConfigurableLAN.MenuManagerPatch));

// Only apply username patches if user wants to
Expand All @@ -115,7 +158,7 @@ private void Awake()
HarmonyLib.PatchAll(typeof(Patches.LatencyHUD.LatencyRPC));
}

this.Logger.LogInfo("sucessfully loaded.");
this.Logger.LogInfo($"{LCDirectLan.PLUGIN_NAME} patches are injected");
}

/// <summary>
Expand Down
6 changes: 6 additions & 0 deletions NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="globalPackagesFolder" value="./packages" />
</config>
</configuration>
Loading

0 comments on commit 22689ab

Please sign in to comment.