-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4cedd9c
commit 76acb77
Showing
88 changed files
with
18,129 additions
and
43 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Binary file not shown.
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,138 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{3FC4C6C1-38BC-432A-87B9-1CAA6D213CE8}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>PEServerPatch</RootNamespace> | ||
<AssemblyName>PEServerPatch</AssemblyName> | ||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<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' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE;UNITY_5; UNITY_BUILD; UNITY_STANDALONE_WIN</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="0Harmony, Version=2.0.1.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Lib.Harmony.2.0.1\lib\net35\0Harmony.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Assembly-CSharp"> | ||
<HintPath>..\PELib\PEServerLib\Assembly-CSharp.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="uLink"> | ||
<HintPath>..\PELib\PEServerLib\uLink.dll</HintPath> | ||
</Reference> | ||
<Reference Include="UnityEngine"> | ||
<HintPath>..\PELib\PEServerLib\UnityEngine.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="PatchInitializer.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="SteamManager.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\isteamapplist.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\isteamapps.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\isteamclient.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\isteamcontroller.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\isteamfriends.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\isteamgameserver.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\isteamgameserverhttp.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\isteamgameserverinventory.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\isteamgameservernetworking.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\isteamgameserverstats.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\isteamgameserverugc.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\isteamgameserverutils.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\isteamhtmlsurface.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\isteamhttp.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\isteaminventory.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\isteammatchmaking.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\isteammusic.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\isteammusicremote.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\isteamnetworking.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\isteamremotestorage.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\isteamscreenshots.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\isteamugc.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\isteamunifiedmessages.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\isteamuser.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\isteamuserstats.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\isteamutils.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\isteamvideo.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\NativeMethods.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\SteamCallbacks.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\SteamConstants.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\SteamEnums.cs" /> | ||
<Compile Include="Steamworks.NET\autogen\SteamStructs.cs" /> | ||
<Compile Include="Steamworks.NET\CallbackDispatcher.cs" /> | ||
<Compile Include="Steamworks.NET\CallbackIdentity.cs" /> | ||
<Compile Include="Steamworks.NET\InteropHelp.cs" /> | ||
<Compile Include="Steamworks.NET\ISteamMatchmakingResponses.cs" /> | ||
<Compile Include="Steamworks.NET\Packsize.cs" /> | ||
<Compile Include="Steamworks.NET\Steam.cs" /> | ||
<Compile Include="Steamworks.NET\types\MatchmakingTypes\gameserveritem_t.cs" /> | ||
<Compile Include="Steamworks.NET\types\MatchmakingTypes\servernetadr_t.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamClientPublic\CGameID.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamClientPublic\CSteamID.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamClientPublic\HAuthTicket.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamClient\HSteamPipe.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamClient\HSteamUser.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamClient\SteamAPIWarningMessageHook_t.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamClient\SteamAPI_CheckCallbackRegistered_t.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamClient\SteamAPI_PostAPIResultInProcess_t.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamFriends\FriendsGroupID_t.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamHTMLSurface\HHTMLBrowser.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamHTTP\HTTPCookieContainerHandle.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamHTTP\HTTPRequestHandle.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamInventory\SteamInventoryResult_t.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamInventory\SteamItemDef_t.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamInventory\SteamItemInstanceID_t.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamMatchmaking\HServerListRequest.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamMatchmaking\HServerQuery.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamNetworking\SNetListenSocket_t.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamNetworking\SNetSocket_t.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamRemoteStorage\PublishedFileId_t.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamRemoteStorage\PublishedFileUpdateHandle_t.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamRemoteStorage\UGCFileWriteStreamHandle_t.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamRemoteStorage\UGCHandle_t.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamScreenshots\ScreenshotHandle.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamTypes\AccountID_t.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamTypes\AppId_t.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamTypes\DepotId_t.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamTypes\ManifestId_t.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamTypes\SteamAPICall_t.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamUGC\UGCQueryHandle_t.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamUGC\UGCUpdateHandle_t.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamUnifiedMessages\ClientUnifiedMessageHandle.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamUserStats\SteamLeaderboardEntries_t.cs" /> | ||
<Compile Include="Steamworks.NET\types\SteamUserStats\SteamLeaderboard_t.cs" /> | ||
<Compile Include="uLinkNetwork_Patch.cs" /> | ||
<Compile Include="uLobbyNetwork_Patch.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using HarmonyLib; | ||
using System.Threading; | ||
|
||
namespace PEServerPatch | ||
{ | ||
public class PatchInitializer | ||
{ | ||
public static void Main() | ||
{ | ||
new Thread(() => | ||
{ | ||
Thread.Sleep(100); | ||
|
||
var harmony = new Harmony("PEServerPatch"); | ||
|
||
harmony.PatchAll(); | ||
}).Start(); | ||
} | ||
} | ||
} |
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,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("PEServerPatch")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("PEServerPatch")] | ||
[assembly: AssemblyCopyright("Copyright © 2020")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("3fc4c6c1-38bc-432a-87b9-1caa6d213ce8")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
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,112 @@ | ||
using Steamworks; | ||
using UnityEngine; | ||
|
||
namespace PEServerPatch | ||
{ | ||
public class SteamManager : MonoBehaviour | ||
{ | ||
private static SteamManager instance; | ||
|
||
public static SteamManager Instance { | ||
get { | ||
if (instance == null) | ||
{ | ||
instance = new GameObject("SteamManager").AddComponent<SteamManager>(); | ||
} | ||
|
||
return instance; | ||
} | ||
} | ||
|
||
private bool initialized; | ||
|
||
private Callback<SteamServersConnected_t> serverConnectedCallback; | ||
private Callback<SteamServerConnectFailure_t> serverNotConnectedCallback; | ||
private Callback<SteamServersDisconnected_t> serverDisconnectedCallback; | ||
|
||
public void Awake() | ||
{ | ||
DontDestroyOnLoad(gameObject); | ||
|
||
ushort port = (ushort)(uLink.Network.listenPort + 20); | ||
|
||
if (ServerConfig.PublicServer == false && port <= 9925) | ||
{ | ||
port = (ushort)(port + 17095); | ||
} | ||
|
||
initialized = Steamworks.GameServer.Init(0u, 0, (ushort)uLink.Network.listenPort, port, EServerMode.eServerModeNoAuthentication, ServerConfig.ServerVersion.Replace("V","")); | ||
|
||
if (!initialized) | ||
{ | ||
Debug.Log("[Steamworks.NET] GameServer_Init() failed. Verify your installation."); | ||
|
||
return; | ||
} | ||
|
||
serverConnectedCallback = Callback<SteamServersConnected_t>.CreateGameServer(ServerConnectedCallback); | ||
serverNotConnectedCallback = Callback<SteamServerConnectFailure_t>.CreateGameServer(ServerNotConnectedCallback); | ||
serverDisconnectedCallback = Callback<SteamServersDisconnected_t>.CreateGameServer(ServerDisconnectedCallback); | ||
} | ||
|
||
public void Update() | ||
{ | ||
if (initialized) | ||
{ | ||
Steamworks.GameServer.RunCallbacks(); | ||
} | ||
} | ||
|
||
public void LogOff() | ||
{ | ||
if (initialized && SteamGameServer.BLoggedOn()) | ||
{ | ||
SteamGameServer.EnableHeartbeats(false); | ||
SteamGameServer.LogOff(); | ||
} | ||
} | ||
|
||
public void LogOn() | ||
{ | ||
SteamGameServer.SetModDir("PlanetExplorers"); | ||
SteamGameServer.SetProduct("PlanetExplorers"); | ||
SteamGameServer.SetGameDescription("Planet Explorers"); | ||
SteamGameServer.LogOnAnonymous(); | ||
} | ||
|
||
public void SetAdditionalGameInfo() | ||
{ | ||
var type = ServerConfig.GameType.ToString(); | ||
var mode = ServerConfig.SceneMode.ToString(); | ||
var UID = ServerConfig.ServerUID.ToString("X"); | ||
var state = (uLinkNetwork.ServerStatus & CustomData.EServerStatus.Gameing) == CustomData.EServerStatus.Gameing ? 4 : 1; | ||
var numPlayers = uLink.Network.connections.Length; | ||
var masterName = ServerConfig.MasterRoleName; | ||
var pub = ServerConfig.PublicServer ? ",public" : ""; | ||
SteamGameServer.SetGameTags($"{type},{mode},{UID},{state},{numPlayers},{masterName}{pub}"); | ||
} | ||
|
||
private void ServerConnectedCallback(SteamServersConnected_t callback) | ||
{ | ||
Debug.Log("[Steamworks.NET] GameServer connected successfully"); | ||
|
||
SteamGameServer.SetServerName(ServerConfig.ServerName); | ||
SteamGameServer.SetPasswordProtected(!string.IsNullOrEmpty(ServerConfig.Password)); | ||
SteamGameServer.SetMaxPlayerCount(ServerConfig.TeamNum * ServerConfig.NumPerTeam); | ||
SteamGameServer.SetMapName(ServerConfig.MapName); | ||
SteamGameServer.SetDedicatedServer(true); | ||
SetAdditionalGameInfo(); | ||
SteamGameServer.EnableHeartbeats(true); | ||
} | ||
|
||
private void ServerNotConnectedCallback(SteamServerConnectFailure_t callback) | ||
{ | ||
Debug.Log($"[Steamworks.NET] GameServer connection failed: {callback.m_eResult}"); | ||
} | ||
|
||
private void ServerDisconnectedCallback(SteamServersDisconnected_t callback) | ||
{ | ||
Debug.Log($"[Steamworks.NET] GameServer disconnected: {callback.m_eResult}"); | ||
} | ||
} | ||
} |
Oops, something went wrong.