This repository has been archived by the owner on Jan 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made Distance.NoServerLimit compliant with the repository coding style
- Loading branch information
Showing
14 changed files
with
235 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
Distance.NoServerLimit.Content/Distance.NoServerLimit.Content.projitems
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects> | ||
<HasSharedItems>true</HasSharedItems> | ||
<SharedGUID>260fe22a-730a-4723-a744-dd06302f92cb</SharedGUID> | ||
</PropertyGroup> | ||
<PropertyGroup Label="Configuration"> | ||
<Import_RootNamespace>Distance.NoServerLimit.Content</Import_RootNamespace> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<None Include="$(MSBuildThisFileDirectory)Mod\mod.json"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
</Project> |
13 changes: 13 additions & 0 deletions
13
Distance.NoServerLimit.Content/Distance.NoServerLimit.Content.shproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>260fe22a-730a-4723-a744-dd06302f92cb</ProjectGuid> | ||
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion> | ||
</PropertyGroup> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" /> | ||
<PropertyGroup /> | ||
<Import Project="Distance.NoServerLimit.Content.projitems" Label="Shared" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using Reactor.API.Configuration; | ||
using System; | ||
using UnityEngine; | ||
|
||
namespace Distance.NoServerLimit | ||
{ | ||
public class ConfigurationLogic : MonoBehaviour | ||
{ | ||
#region Properties | ||
public int MaxPlayerCount | ||
{ | ||
get => Get<int>("MaxPlayerCount"); | ||
set => Set("MaxPlayerCount", value); | ||
} | ||
#endregion | ||
|
||
internal Settings Config; | ||
|
||
public event Action<ConfigurationLogic> OnChanged; | ||
|
||
private void Load() | ||
{ | ||
Config = new Settings("Server"); | ||
} | ||
|
||
public void Awake() | ||
{ | ||
Load(); | ||
|
||
Get("MaxPlayerCount", 32); | ||
|
||
Save(); | ||
} | ||
|
||
public T Get<T>(string key, T @default = default) | ||
{ | ||
return Config.GetOrCreate(key, @default); | ||
} | ||
|
||
public void Set<T>(string key, T value) | ||
{ | ||
Config[key] = value; | ||
Save(); | ||
} | ||
|
||
public void Save() | ||
{ | ||
Config?.Save(); | ||
OnChanged?.Invoke(this); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
Distance.NoServerLimit/Harmony/Assembly-CSharp/HostAGame/IncrementMaxPlayers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Harmony; | ||
|
||
namespace Distance.NoServerLimit.Harmony | ||
{ | ||
[HarmonyPatch(typeof(HostAGame), "IncrementMaxPlayers")] | ||
internal class HostAGame__IncrementMaxPlayers | ||
{ | ||
internal static bool Prefix(HostAGame __instance, int direction) | ||
{ | ||
__instance.internalMaxPlayerCalc_ = GUtils.mod(__instance.internalMaxPlayerCalc_ + direction, Mod.Instance.Config.MaxPlayerCount); | ||
__instance.maxPlayersLabel_.text = __instance.MaxPlayers_.ToString(); | ||
|
||
if (direction != 0 && AudioManager.Valid()) | ||
{ | ||
G.Sys.AudioManager_.PlaySound("ButtonSelect", "Menus", 1f); | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
Distance.NoServerLimit/Harmony/Assembly-CSharp/NetworkingManager/CreateServer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using Harmony; | ||
using System; | ||
using UnityEngine; | ||
|
||
namespace Distance.NoServerLimit.Harmony | ||
{ | ||
[HarmonyPatch(typeof(NetworkingManager), "CreateServer")] | ||
internal class NetworkingManager__CreateServer | ||
{ | ||
internal static bool Prefix(NetworkingManager __instance, string serverTitle, string password, int maxPlayerCount) | ||
{ | ||
Network.InitializeSecurity(); | ||
|
||
try | ||
{ | ||
__instance.password_ = password; | ||
__instance.serverTitle_ = serverTitle; | ||
|
||
G.Sys.GameData_.SetString("ServerTitleDefault", __instance.serverTitle_); | ||
|
||
__instance.maxPlayerCount_ = Mathf.Clamp(maxPlayerCount, 1, Mod.Instance.Config.MaxPlayerCount); | ||
|
||
G.Sys.GameData_.SetInt("MaxPlayersDefault", __instance.maxPlayerCount_); | ||
|
||
int num = 1; | ||
int connections = __instance.maxPlayerCount_ - num; | ||
|
||
NetworkConnectionError networkConnectionError = Network.InitializeServer(connections, 32323, true); | ||
|
||
if (networkConnectionError != NetworkConnectionError.NoError) | ||
{ | ||
G.Sys.MenuPanelManager_.ShowError("Failed to create game lobby. Error code: " + networkConnectionError.ToString(), "Network Error", null, UIWidget.Pivot.Center); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
Debug.LogError(ex.Message); | ||
Mod.Instance.Logger.Exception(ex); | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.