forked from rlabrecque/Steamworks.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert project structure to support Unity Packages (rlabrecque#414)
* Initial attempt at restructuring for Unity's package format * Add LICENSE.md and README.md * Import Steamworks.NET-CodeGen from b34d84c7aadeb4fe19141f690c644f4b15142a9b * Update Standalone file paths * Add missing libsteam_api.dylib ??
- Loading branch information
1 parent
3403ce0
commit 510d992
Showing
356 changed files
with
35,706 additions
and
765 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "CodeGen/SteamworksParser"] | ||
path = CodeGen/SteamworksParser | ||
url = https://github.com/rlabrecque/SteamworksParser.git |
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,4 @@ | ||
/__pycache__/ | ||
/autogen/ | ||
/types/ | ||
/steam/lib/ |
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,90 @@ | ||
using System.Text; | ||
|
||
namespace Steamworks { | ||
//----------------------------------------------------------------------------- | ||
// Purpose: Data describing a single server | ||
//----------------------------------------------------------------------------- | ||
[StructLayout(LayoutKind.Sequential, Size = 372, Pack = 4)] | ||
[System.Serializable] | ||
public class gameserveritem_t { | ||
public string GetGameDir() { | ||
return Encoding.UTF8.GetString(m_szGameDir, 0, System.Array.IndexOf<byte>(m_szGameDir, 0)); | ||
} | ||
|
||
public void SetGameDir(string dir) { | ||
m_szGameDir = Encoding.UTF8.GetBytes(dir + '\0'); | ||
} | ||
|
||
public string GetMap() { | ||
return Encoding.UTF8.GetString(m_szMap, 0, System.Array.IndexOf<byte>(m_szMap, 0)); | ||
} | ||
|
||
public void SetMap(string map) { | ||
m_szMap = Encoding.UTF8.GetBytes(map + '\0'); | ||
} | ||
|
||
public string GetGameDescription() { | ||
return Encoding.UTF8.GetString(m_szGameDescription, 0, System.Array.IndexOf<byte>(m_szGameDescription, 0)); | ||
} | ||
|
||
public void SetGameDescription(string desc) { | ||
m_szGameDescription = Encoding.UTF8.GetBytes(desc + '\0'); | ||
} | ||
|
||
public string GetServerName() { | ||
// Use the IP address as the name if nothing is set yet. | ||
if (m_szServerName[0] == 0) | ||
return m_NetAdr.GetConnectionAddressString(); | ||
else | ||
return Encoding.UTF8.GetString(m_szServerName, 0, System.Array.IndexOf<byte>(m_szServerName, 0)); | ||
} | ||
|
||
public void SetServerName(string name) { | ||
m_szServerName = Encoding.UTF8.GetBytes(name + '\0'); | ||
} | ||
|
||
public string GetGameTags() { | ||
return Encoding.UTF8.GetString(m_szGameTags, 0, System.Array.IndexOf<byte>(m_szGameTags, 0)); | ||
} | ||
|
||
public void SetGameTags(string tags) { | ||
m_szGameTags = Encoding.UTF8.GetBytes(tags + '\0'); | ||
} | ||
|
||
public servernetadr_t m_NetAdr; ///< IP/Query Port/Connection Port for this server | ||
public int m_nPing; ///< current ping time in milliseconds | ||
[MarshalAs(UnmanagedType.I1)] | ||
public bool m_bHadSuccessfulResponse; ///< server has responded successfully in the past | ||
[MarshalAs(UnmanagedType.I1)] | ||
public bool m_bDoNotRefresh; ///< server is marked as not responding and should no longer be refreshed | ||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = Constants.k_cbMaxGameServerGameDir)] | ||
private byte[] m_szGameDir; ///< current game directory | ||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = Constants.k_cbMaxGameServerMapName)] | ||
private byte[] m_szMap; ///< current map | ||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = Constants.k_cbMaxGameServerGameDescription)] | ||
private byte[] m_szGameDescription; ///< game description | ||
public uint m_nAppID; ///< Steam App ID of this server | ||
public int m_nPlayers; ///< total number of players currently on the server. INCLUDES BOTS!! | ||
public int m_nMaxPlayers; ///< Maximum players that can join this server | ||
public int m_nBotPlayers; ///< Number of bots (i.e simulated players) on this server | ||
[MarshalAs(UnmanagedType.I1)] | ||
public bool m_bPassword; ///< true if this server needs a password to join | ||
[MarshalAs(UnmanagedType.I1)] | ||
public bool m_bSecure; ///< Is this server protected by VAC | ||
public uint m_ulTimeLastPlayed; ///< time (in unix time) when this server was last played on (for favorite/history servers) | ||
public int m_nServerVersion; ///< server version as reported to Steam | ||
|
||
// Game server name | ||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = Constants.k_cbMaxGameServerName)] | ||
private byte[] m_szServerName; | ||
|
||
// the tags this server exposes | ||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = Constants.k_cbMaxGameServerTags)] | ||
private byte[] m_szGameTags; | ||
|
||
// steamID of the game server - invalid if it's doesn't have one (old server, or not connected to Steam) | ||
public CSteamID m_steamID; | ||
} | ||
} | ||
|
||
#endif // !DISABLESTEAMWORKS |
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,100 @@ | ||
namespace Steamworks { | ||
// servernetadr_t is all the addressing info the serverbrowser needs to know about a game server, | ||
// namely: its IP, its connection port, and its query port. | ||
[System.Serializable] | ||
public struct servernetadr_t { | ||
private ushort m_usConnectionPort; // (in HOST byte order) | ||
private ushort m_usQueryPort; | ||
private uint m_unIP; | ||
|
||
public void Init(uint ip, ushort usQueryPort, ushort usConnectionPort) { | ||
m_unIP = ip; | ||
m_usQueryPort = usQueryPort; | ||
m_usConnectionPort = usConnectionPort; | ||
} | ||
|
||
#if NETADR_H | ||
public netadr_t GetIPAndQueryPort() { | ||
return netadr_t( m_unIP, m_usQueryPort ); | ||
} | ||
#endif | ||
|
||
// Access the query port. | ||
public ushort GetQueryPort() { | ||
return m_usQueryPort; | ||
} | ||
|
||
public void SetQueryPort(ushort usPort) { | ||
m_usQueryPort = usPort; | ||
} | ||
|
||
// Access the connection port. | ||
public ushort GetConnectionPort() { | ||
return m_usConnectionPort; | ||
} | ||
|
||
public void SetConnectionPort(ushort usPort) { | ||
m_usConnectionPort = usPort; | ||
} | ||
|
||
// Access the IP | ||
public uint GetIP() { | ||
return m_unIP; | ||
} | ||
|
||
public void SetIP(uint unIP) { | ||
m_unIP = unIP; | ||
} | ||
|
||
// This gets the 'a.b.c.d:port' string with the connection port (instead of the query port). | ||
public string GetConnectionAddressString() { | ||
return ToString(m_unIP, m_usConnectionPort); | ||
} | ||
|
||
public string GetQueryAddressString() { | ||
return ToString(m_unIP, m_usQueryPort); | ||
} | ||
|
||
public static string ToString(uint unIP, ushort usPort) { | ||
#if VALVE_BIG_ENDIAN | ||
return string.Format("{0}.{1}.{2}.{3}:{4}", unIP & 0xFFul, (unIP >> 8) & 0xFFul, (unIP >> 16) & 0xFFul, (unIP >> 24) & 0xFFul, usPort); | ||
#else | ||
return string.Format("{0}.{1}.{2}.{3}:{4}", (unIP >> 24) & 0xFFul, (unIP >> 16) & 0xFFul, (unIP >> 8) & 0xFFul, unIP & 0xFFul, usPort); | ||
#endif | ||
} | ||
|
||
public static bool operator <(servernetadr_t x, servernetadr_t y) { | ||
return (x.m_unIP < y.m_unIP) || (x.m_unIP == y.m_unIP && x.m_usQueryPort < y.m_usQueryPort); | ||
} | ||
|
||
public static bool operator >(servernetadr_t x, servernetadr_t y) { | ||
return (x.m_unIP > y.m_unIP) || (x.m_unIP == y.m_unIP && x.m_usQueryPort > y.m_usQueryPort); | ||
} | ||
|
||
public override bool Equals(object other) { | ||
return other is servernetadr_t && this == (servernetadr_t)other; | ||
} | ||
|
||
public override int GetHashCode() { | ||
return m_unIP.GetHashCode() + m_usQueryPort.GetHashCode() + m_usConnectionPort.GetHashCode(); | ||
} | ||
|
||
public static bool operator ==(servernetadr_t x, servernetadr_t y) { | ||
return (x.m_unIP == y.m_unIP) && (x.m_usQueryPort == y.m_usQueryPort) && (x.m_usConnectionPort == y.m_usConnectionPort); | ||
} | ||
|
||
public static bool operator !=(servernetadr_t x, servernetadr_t y) { | ||
return !(x == y); | ||
} | ||
|
||
public bool Equals(servernetadr_t other) { | ||
return (m_unIP == other.m_unIP) && (m_usQueryPort == other.m_usQueryPort) && (m_usConnectionPort == other.m_usConnectionPort); | ||
} | ||
|
||
public int CompareTo(servernetadr_t other) { | ||
return m_unIP.CompareTo(other.m_unIP) + m_usQueryPort.CompareTo(other.m_usQueryPort) + m_usConnectionPort.CompareTo(other.m_usConnectionPort); | ||
} | ||
} | ||
} | ||
|
||
#endif // !DISABLESTEAMWORKS |
6 changes: 6 additions & 0 deletions
6
CodeGen/CustomTypes/SteamClient/SteamAPIWarningMessageHook_t.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,6 @@ | ||
namespace Steamworks { | ||
[System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.Cdecl)] | ||
public delegate void SteamAPIWarningMessageHook_t(int nSeverity, System.Text.StringBuilder pchDebugText); | ||
} | ||
|
||
#endif // !DISABLESTEAMWORKS |
6 changes: 6 additions & 0 deletions
6
CodeGen/CustomTypes/SteamClient/SteamAPI_CheckCallbackRegistered_t.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,6 @@ | ||
namespace Steamworks { | ||
[System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] // TODO: This is probably wrong, will likely crash on some platform. | ||
public delegate void SteamAPI_CheckCallbackRegistered_t(int iCallbackNum); | ||
} | ||
|
||
#endif // !DISABLESTEAMWORKS |
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 @@ | ||
namespace Steamworks { | ||
[System.Serializable] | ||
public struct CGameID : System.IEquatable<CGameID>, System.IComparable<CGameID> { | ||
public ulong m_GameID; | ||
|
||
public enum EGameIDType { | ||
k_EGameIDTypeApp = 0, | ||
k_EGameIDTypeGameMod = 1, | ||
k_EGameIDTypeShortcut = 2, | ||
k_EGameIDTypeP2P = 3, | ||
}; | ||
|
||
public CGameID(ulong GameID) { | ||
m_GameID = GameID; | ||
} | ||
|
||
public CGameID(AppId_t nAppID) { | ||
m_GameID = 0; | ||
SetAppID(nAppID); | ||
} | ||
|
||
public CGameID(AppId_t nAppID, uint nModID) { | ||
m_GameID = 0; | ||
SetAppID(nAppID); | ||
SetType(EGameIDType.k_EGameIDTypeGameMod); | ||
SetModID(nModID); | ||
} | ||
|
||
public bool IsSteamApp() { | ||
return Type() == EGameIDType.k_EGameIDTypeApp; | ||
} | ||
|
||
public bool IsMod() { | ||
return Type() == EGameIDType.k_EGameIDTypeGameMod; | ||
} | ||
|
||
public bool IsShortcut() { | ||
return Type() == EGameIDType.k_EGameIDTypeShortcut; | ||
} | ||
|
||
public bool IsP2PFile() { | ||
return Type() == EGameIDType.k_EGameIDTypeP2P; | ||
} | ||
|
||
public AppId_t AppID() { | ||
return new AppId_t((uint)(m_GameID & 0xFFFFFFul)); | ||
} | ||
|
||
public EGameIDType Type() { | ||
return (EGameIDType)((m_GameID >> 24) & 0xFFul); | ||
} | ||
|
||
public uint ModID() { | ||
return (uint)((m_GameID >> 32) & 0xFFFFFFFFul); | ||
} | ||
|
||
public bool IsValid() { | ||
// Each type has it's own invalid fixed point: | ||
switch (Type()) { | ||
case EGameIDType.k_EGameIDTypeApp: | ||
return AppID() != AppId_t.Invalid; | ||
|
||
case EGameIDType.k_EGameIDTypeGameMod: | ||
return AppID() != AppId_t.Invalid && (ModID() & 0x80000000) != 0; | ||
|
||
case EGameIDType.k_EGameIDTypeShortcut: | ||
return (ModID() & 0x80000000) != 0; | ||
|
||
case EGameIDType.k_EGameIDTypeP2P: | ||
return AppID() == AppId_t.Invalid && (ModID() & 0x80000000) != 0; | ||
|
||
default: | ||
return false; | ||
} | ||
} | ||
|
||
public void Reset() { | ||
m_GameID = 0; | ||
} | ||
|
||
public void Set(ulong GameID) { | ||
m_GameID = GameID; | ||
} | ||
|
||
#region Private Setters for internal use | ||
private void SetAppID(AppId_t other) { | ||
m_GameID = (m_GameID & ~(0xFFFFFFul << (ushort)0)) | (((ulong)(other) & 0xFFFFFFul) << (ushort)0); | ||
} | ||
|
||
private void SetType(EGameIDType other) { | ||
m_GameID = (m_GameID & ~(0xFFul << (ushort)24)) | (((ulong)(other) & 0xFFul) << (ushort)24); | ||
} | ||
|
||
private void SetModID(uint other) { | ||
m_GameID = (m_GameID & ~(0xFFFFFFFFul << (ushort)32)) | (((ulong)(other) & 0xFFFFFFFFul) << (ushort)32); | ||
} | ||
#endregion | ||
|
||
#region Overrides | ||
public override string ToString() { | ||
return m_GameID.ToString(); | ||
} | ||
|
||
public override bool Equals(object other) { | ||
return other is CGameID && this == (CGameID)other; | ||
} | ||
|
||
public override int GetHashCode() { | ||
return m_GameID.GetHashCode(); | ||
} | ||
|
||
public static bool operator ==(CGameID x, CGameID y) { | ||
return x.m_GameID == y.m_GameID; | ||
} | ||
|
||
public static bool operator !=(CGameID x, CGameID y) { | ||
return !(x == y); | ||
} | ||
|
||
public static explicit operator CGameID(ulong value) { | ||
return new CGameID(value); | ||
} | ||
public static explicit operator ulong(CGameID that) { | ||
return that.m_GameID; | ||
} | ||
|
||
public bool Equals(CGameID other) { | ||
return m_GameID == other.m_GameID; | ||
} | ||
|
||
public int CompareTo(CGameID other) { | ||
return m_GameID.CompareTo(other.m_GameID); | ||
} | ||
#endregion | ||
} | ||
} | ||
|
||
#endif // !DISABLESTEAMWORKS |
Oops, something went wrong.