(f2e516dfe) v0.9.3.2

This commit is contained in:
Joonas Rikkonen
2019-09-20 20:11:18 +03:00
parent 80698b58b0
commit 9aa12bcac2
144 changed files with 1653 additions and 1559 deletions
@@ -448,9 +448,16 @@ namespace Facepunch.Steamworks
/// <returns>Array of member SteamIDs</returns>
public ulong[] GetMemberIDs()
{
ulong[] memIDs = new ulong[NumMembers];
for ( int i = 0; i < NumMembers; i++ )
int numMembers = NumMembers;
ulong[] memIDs = new ulong[numMembers];
for ( int i = 0; i < numMembers; i++ )
{
int currNumMembers = NumMembers;
if (i >= currNumMembers)
{
Array.Resize<ulong>(ref memIDs, currNumMembers);
break;
}
memIDs[i] = client.native.matchmaking.GetLobbyMemberByIndex( CurrentLobby, i );
}
return memIDs;
@@ -41,8 +41,9 @@ namespace Facepunch.Steamworks
{
filter = new Filter();
filter.StringFilters.Add("appid", client.AppId.ToString());
client.native.matchmaking.RequestLobbyList(OnLobbyList);
return;
filter.DistanceFilter = Filter.Distance.Worldwide;
//client.native.matchmaking.RequestLobbyList(OnLobbyList);
//return;
}
client.native.matchmaking.AddRequestLobbyListDistanceFilter((SteamNative.LobbyDistanceFilter)filter.DistanceFilter);
@@ -123,7 +123,9 @@ namespace Facepunch.Steamworks
void ResultCallback( SteamNative.SteamUGCQueryCompleted_t data, bool bFailed )
{
if ( bFailed )
throw new System.Exception( "bFailed!" );
{
throw new System.Exception("Steam UGC Query failed: "+data.Result.ToString());
}
var gotFiles = 0;
for ( int i = 0; i < data.NumResultsReturned; i++ )
@@ -349,7 +349,7 @@ namespace SteamNative
int /*int*/ ISteamMatchmaking_GetNumLobbyMembers( ulong steamIDLobby );
CSteamID /*(class CSteamID)*/ ISteamMatchmaking_GetLobbyMemberByIndex( ulong steamIDLobby, int /*int*/ iMember );
IntPtr ISteamMatchmaking_GetLobbyData( ulong steamIDLobby, string /*const char **/ pchKey );
bool /*bool*/ ISteamMatchmaking_SetLobbyData( ulong steamIDLobby, string /*const char **/ pchKey, string /*const char **/ pchValue );
bool /*bool*/ ISteamMatchmaking_SetLobbyData( ulong steamIDLobby, IntPtr /*const char **/ pchKey, IntPtr /*const char **/ pchValue );
int /*int*/ ISteamMatchmaking_GetLobbyDataCount( ulong steamIDLobby );
bool /*bool*/ ISteamMatchmaking_GetLobbyDataByIndex( ulong steamIDLobby, int /*int*/ iLobbyData, System.Text.StringBuilder /*char **/ pchKey, int /*int*/ cchKeyBufferSize, System.Text.StringBuilder /*char **/ pchValue, int /*int*/ cchValueBufferSize );
bool /*bool*/ ISteamMatchmaking_DeleteLobbyData( ulong steamIDLobby, string /*const char **/ pchKey );
@@ -1125,7 +1125,7 @@ namespace SteamNative
return Native.SteamAPI_ISteamMatchmaking_GetLobbyData(_ptr, steamIDLobby, pchKey);
}
public virtual bool /*bool*/ ISteamMatchmaking_SetLobbyData( ulong steamIDLobby, string /*const char **/ pchKey, string /*const char **/ pchValue )
public virtual bool /*bool*/ ISteamMatchmaking_SetLobbyData( ulong steamIDLobby, IntPtr /*const char **/ pchKey, IntPtr /*const char **/ pchValue )
{
if ( _ptr == IntPtr.Zero ) throw new System.Exception( "ISteamMatchmaking _ptr is null!" );
@@ -4461,7 +4461,7 @@ namespace SteamNative
[DllImport( "libsteam_api.so", CallingConvention = CallingConvention.Cdecl )] internal static extern int /*int*/ SteamAPI_ISteamMatchmaking_GetNumLobbyMembers( IntPtr ISteamMatchmaking, ulong steamIDLobby );
[DllImport( "libsteam_api.so", CallingConvention = CallingConvention.Cdecl )] internal static extern CSteamID /*(class CSteamID)*/ SteamAPI_ISteamMatchmaking_GetLobbyMemberByIndex( IntPtr ISteamMatchmaking, ulong steamIDLobby, int /*int*/ iMember );
[DllImport( "libsteam_api.so", CallingConvention = CallingConvention.Cdecl )] internal static extern IntPtr SteamAPI_ISteamMatchmaking_GetLobbyData( IntPtr ISteamMatchmaking, ulong steamIDLobby, string /*const char **/ pchKey );
[DllImport( "libsteam_api.so", CallingConvention = CallingConvention.Cdecl )] internal static extern bool /*bool*/ SteamAPI_ISteamMatchmaking_SetLobbyData( IntPtr ISteamMatchmaking, ulong steamIDLobby, string /*const char **/ pchKey, string /*const char **/ pchValue );
[DllImport( "libsteam_api.so", CallingConvention = CallingConvention.Cdecl )] internal static extern bool /*bool*/ SteamAPI_ISteamMatchmaking_SetLobbyData( IntPtr ISteamMatchmaking, ulong steamIDLobby, IntPtr /*const char **/ pchKey, IntPtr /*const char **/ pchValue );
[DllImport( "libsteam_api.so", CallingConvention = CallingConvention.Cdecl )] internal static extern int /*int*/ SteamAPI_ISteamMatchmaking_GetLobbyDataCount( IntPtr ISteamMatchmaking, ulong steamIDLobby );
[DllImport( "libsteam_api.so", CallingConvention = CallingConvention.Cdecl )] internal static extern bool /*bool*/ SteamAPI_ISteamMatchmaking_GetLobbyDataByIndex( IntPtr ISteamMatchmaking, ulong steamIDLobby, int /*int*/ iLobbyData, System.Text.StringBuilder /*char **/ pchKey, int /*int*/ cchKeyBufferSize, System.Text.StringBuilder /*char **/ pchValue, int /*int*/ cchValueBufferSize );
[DllImport( "libsteam_api.so", CallingConvention = CallingConvention.Cdecl )] internal static extern bool /*bool*/ SteamAPI_ISteamMatchmaking_DeleteLobbyData( IntPtr ISteamMatchmaking, ulong steamIDLobby, string /*const char **/ pchKey );
@@ -1125,7 +1125,7 @@ namespace SteamNative
return Native.SteamAPI_ISteamMatchmaking_GetLobbyData(_ptr, steamIDLobby, pchKey);
}
public virtual bool /*bool*/ ISteamMatchmaking_SetLobbyData( ulong steamIDLobby, string /*const char **/ pchKey, string /*const char **/ pchValue )
public virtual bool /*bool*/ ISteamMatchmaking_SetLobbyData( ulong steamIDLobby, IntPtr /*const char **/ pchKey, IntPtr /*const char **/ pchValue )
{
if ( _ptr == IntPtr.Zero ) throw new System.Exception( "ISteamMatchmaking _ptr is null!" );
@@ -4461,7 +4461,7 @@ namespace SteamNative
[DllImport( "libsteam_api64.so" )] internal static extern int /*int*/ SteamAPI_ISteamMatchmaking_GetNumLobbyMembers( IntPtr ISteamMatchmaking, ulong steamIDLobby );
[DllImport( "libsteam_api64.so" )] internal static extern CSteamID /*(class CSteamID)*/ SteamAPI_ISteamMatchmaking_GetLobbyMemberByIndex( IntPtr ISteamMatchmaking, ulong steamIDLobby, int /*int*/ iMember );
[DllImport( "libsteam_api64.so" )] internal static extern IntPtr SteamAPI_ISteamMatchmaking_GetLobbyData( IntPtr ISteamMatchmaking, ulong steamIDLobby, string /*const char **/ pchKey );
[DllImport( "libsteam_api64.so" )] internal static extern bool /*bool*/ SteamAPI_ISteamMatchmaking_SetLobbyData( IntPtr ISteamMatchmaking, ulong steamIDLobby, string /*const char **/ pchKey, string /*const char **/ pchValue );
[DllImport( "libsteam_api64.so" )] internal static extern bool /*bool*/ SteamAPI_ISteamMatchmaking_SetLobbyData( IntPtr ISteamMatchmaking, ulong steamIDLobby, IntPtr /*const char **/ pchKey, IntPtr /*const char **/ pchValue );
[DllImport( "libsteam_api64.so" )] internal static extern int /*int*/ SteamAPI_ISteamMatchmaking_GetLobbyDataCount( IntPtr ISteamMatchmaking, ulong steamIDLobby );
[DllImport( "libsteam_api64.so" )] internal static extern bool /*bool*/ SteamAPI_ISteamMatchmaking_GetLobbyDataByIndex( IntPtr ISteamMatchmaking, ulong steamIDLobby, int /*int*/ iLobbyData, System.Text.StringBuilder /*char **/ pchKey, int /*int*/ cchKeyBufferSize, System.Text.StringBuilder /*char **/ pchValue, int /*int*/ cchValueBufferSize );
[DllImport( "libsteam_api64.so" )] internal static extern bool /*bool*/ SteamAPI_ISteamMatchmaking_DeleteLobbyData( IntPtr ISteamMatchmaking, ulong steamIDLobby, string /*const char **/ pchKey );
@@ -1125,7 +1125,7 @@ namespace SteamNative
return Native.SteamAPI_ISteamMatchmaking_GetLobbyData(_ptr, steamIDLobby, pchKey);
}
public virtual bool /*bool*/ ISteamMatchmaking_SetLobbyData( ulong steamIDLobby, string /*const char **/ pchKey, string /*const char **/ pchValue )
public virtual bool /*bool*/ ISteamMatchmaking_SetLobbyData( ulong steamIDLobby, IntPtr /*const char **/ pchKey, IntPtr /*const char **/ pchValue )
{
if ( _ptr == IntPtr.Zero ) throw new System.Exception( "ISteamMatchmaking _ptr is null!" );
@@ -4461,7 +4461,7 @@ namespace SteamNative
[DllImport( "libsteam_api.dylib" )] internal static extern int /*int*/ SteamAPI_ISteamMatchmaking_GetNumLobbyMembers( IntPtr ISteamMatchmaking, ulong steamIDLobby );
[DllImport( "libsteam_api.dylib" )] internal static extern CSteamID /*(class CSteamID)*/ SteamAPI_ISteamMatchmaking_GetLobbyMemberByIndex( IntPtr ISteamMatchmaking, ulong steamIDLobby, int /*int*/ iMember );
[DllImport( "libsteam_api.dylib" )] internal static extern IntPtr SteamAPI_ISteamMatchmaking_GetLobbyData( IntPtr ISteamMatchmaking, ulong steamIDLobby, string /*const char **/ pchKey );
[DllImport( "libsteam_api.dylib" )] internal static extern bool /*bool*/ SteamAPI_ISteamMatchmaking_SetLobbyData( IntPtr ISteamMatchmaking, ulong steamIDLobby, string /*const char **/ pchKey, string /*const char **/ pchValue );
[DllImport( "libsteam_api.dylib" )] internal static extern bool /*bool*/ SteamAPI_ISteamMatchmaking_SetLobbyData( IntPtr ISteamMatchmaking, ulong steamIDLobby, IntPtr /*const char **/ pchKey, IntPtr /*const char **/ pchValue );
[DllImport( "libsteam_api.dylib" )] internal static extern int /*int*/ SteamAPI_ISteamMatchmaking_GetLobbyDataCount( IntPtr ISteamMatchmaking, ulong steamIDLobby );
[DllImport( "libsteam_api.dylib" )] internal static extern bool /*bool*/ SteamAPI_ISteamMatchmaking_GetLobbyDataByIndex( IntPtr ISteamMatchmaking, ulong steamIDLobby, int /*int*/ iLobbyData, System.Text.StringBuilder /*char **/ pchKey, int /*int*/ cchKeyBufferSize, System.Text.StringBuilder /*char **/ pchValue, int /*int*/ cchValueBufferSize );
[DllImport( "libsteam_api.dylib" )] internal static extern bool /*bool*/ SteamAPI_ISteamMatchmaking_DeleteLobbyData( IntPtr ISteamMatchmaking, ulong steamIDLobby, string /*const char **/ pchKey );
@@ -1122,7 +1122,7 @@ namespace SteamNative
return Native.SteamAPI_ISteamMatchmaking_GetLobbyData(_ptr, steamIDLobby, pchKey);
}
public virtual bool /*bool*/ ISteamMatchmaking_SetLobbyData( ulong steamIDLobby, string /*const char **/ pchKey, string /*const char **/ pchValue )
public virtual bool /*bool*/ ISteamMatchmaking_SetLobbyData( ulong steamIDLobby, IntPtr /*const char **/ pchKey, IntPtr /*const char **/ pchValue )
{
if ( _ptr == IntPtr.Zero ) throw new System.Exception( "ISteamMatchmaking _ptr is null!" );
@@ -4427,7 +4427,7 @@ namespace SteamNative
[DllImport( "steam_api.dll", CallingConvention = CallingConvention.Cdecl )] internal static extern int /*int*/ SteamAPI_ISteamMatchmaking_GetNumLobbyMembers( IntPtr ISteamMatchmaking, ulong steamIDLobby );
[DllImport( "steam_api.dll", CallingConvention = CallingConvention.Cdecl )] internal static extern CSteamID /*(class CSteamID)*/ SteamAPI_ISteamMatchmaking_GetLobbyMemberByIndex( IntPtr ISteamMatchmaking, ulong steamIDLobby, int /*int*/ iMember );
[DllImport( "steam_api.dll", CallingConvention = CallingConvention.Cdecl )] internal static extern IntPtr SteamAPI_ISteamMatchmaking_GetLobbyData( IntPtr ISteamMatchmaking, ulong steamIDLobby, string /*const char **/ pchKey );
[DllImport( "steam_api.dll", CallingConvention = CallingConvention.Cdecl )] internal static extern bool /*bool*/ SteamAPI_ISteamMatchmaking_SetLobbyData( IntPtr ISteamMatchmaking, ulong steamIDLobby, string /*const char **/ pchKey, string /*const char **/ pchValue );
[DllImport( "steam_api.dll", CallingConvention = CallingConvention.Cdecl )] internal static extern bool /*bool*/ SteamAPI_ISteamMatchmaking_SetLobbyData( IntPtr ISteamMatchmaking, ulong steamIDLobby, IntPtr /*const char **/ pchKey, IntPtr /*const char **/ pchValue );
[DllImport( "steam_api.dll", CallingConvention = CallingConvention.Cdecl )] internal static extern int /*int*/ SteamAPI_ISteamMatchmaking_GetLobbyDataCount( IntPtr ISteamMatchmaking, ulong steamIDLobby );
[DllImport( "steam_api.dll", CallingConvention = CallingConvention.Cdecl )] internal static extern bool /*bool*/ SteamAPI_ISteamMatchmaking_GetLobbyDataByIndex( IntPtr ISteamMatchmaking, ulong steamIDLobby, int /*int*/ iLobbyData, System.Text.StringBuilder /*char **/ pchKey, int /*int*/ cchKeyBufferSize, System.Text.StringBuilder /*char **/ pchValue, int /*int*/ cchValueBufferSize );
[DllImport( "steam_api.dll", CallingConvention = CallingConvention.Cdecl )] internal static extern bool /*bool*/ SteamAPI_ISteamMatchmaking_DeleteLobbyData( IntPtr ISteamMatchmaking, ulong steamIDLobby, string /*const char **/ pchKey );
@@ -1122,7 +1122,7 @@ namespace SteamNative
return Native.SteamAPI_ISteamMatchmaking_GetLobbyData(_ptr, steamIDLobby, pchKey);
}
public virtual bool /*bool*/ ISteamMatchmaking_SetLobbyData( ulong steamIDLobby, string /*const char **/ pchKey, string /*const char **/ pchValue )
public virtual bool /*bool*/ ISteamMatchmaking_SetLobbyData( ulong steamIDLobby, IntPtr /*const char **/ pchKey, IntPtr /*const char **/ pchValue )
{
if ( _ptr == IntPtr.Zero ) throw new System.Exception( "ISteamMatchmaking _ptr is null!" );
@@ -4427,7 +4427,7 @@ namespace SteamNative
[DllImport( "steam_api64.dll" )] internal static extern int /*int*/ SteamAPI_ISteamMatchmaking_GetNumLobbyMembers( IntPtr ISteamMatchmaking, ulong steamIDLobby );
[DllImport( "steam_api64.dll" )] internal static extern CSteamID /*(class CSteamID)*/ SteamAPI_ISteamMatchmaking_GetLobbyMemberByIndex( IntPtr ISteamMatchmaking, ulong steamIDLobby, int /*int*/ iMember );
[DllImport( "steam_api64.dll" )] internal static extern IntPtr SteamAPI_ISteamMatchmaking_GetLobbyData( IntPtr ISteamMatchmaking, ulong steamIDLobby, string /*const char **/ pchKey );
[DllImport( "steam_api64.dll" )] internal static extern bool /*bool*/ SteamAPI_ISteamMatchmaking_SetLobbyData( IntPtr ISteamMatchmaking, ulong steamIDLobby, string /*const char **/ pchKey, string /*const char **/ pchValue );
[DllImport( "steam_api64.dll" )] internal static extern bool /*bool*/ SteamAPI_ISteamMatchmaking_SetLobbyData( IntPtr ISteamMatchmaking, ulong steamIDLobby, IntPtr /*const char **/ pchKey, IntPtr /*const char **/ pchValue );
[DllImport( "steam_api64.dll" )] internal static extern int /*int*/ SteamAPI_ISteamMatchmaking_GetLobbyDataCount( IntPtr ISteamMatchmaking, ulong steamIDLobby );
[DllImport( "steam_api64.dll" )] internal static extern bool /*bool*/ SteamAPI_ISteamMatchmaking_GetLobbyDataByIndex( IntPtr ISteamMatchmaking, ulong steamIDLobby, int /*int*/ iLobbyData, System.Text.StringBuilder /*char **/ pchKey, int /*int*/ cchKeyBufferSize, System.Text.StringBuilder /*char **/ pchValue, int /*int*/ cchValueBufferSize );
[DllImport( "steam_api64.dll" )] internal static extern bool /*bool*/ SteamAPI_ISteamMatchmaking_DeleteLobbyData( IntPtr ISteamMatchmaking, ulong steamIDLobby, string /*const char **/ pchKey );
@@ -1,6 +1,8 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
using System.Collections.Generic;
using System.Text;
namespace SteamNative
{
@@ -139,7 +141,30 @@ namespace SteamNative
{
IntPtr string_pointer;
string_pointer = platform.ISteamMatchmaking_GetLobbyData( steamIDLobby.Value, pchKey );
return Marshal.PtrToStringAnsi( string_pointer );
//steamworks documentation says this returns empty string,
//just gonna check for good measure
if (string_pointer == IntPtr.Zero) { return string.Empty; }
//ugliest try-catch of my life, it's here because SOMETHING might still be up with this method! >:(
try
{
//also gonna do some manual marshalling here 'cause Mono's broken or something, idk
List<byte> bytes = new List<byte>();
IntPtr seekPointer = string_pointer;
byte b = Marshal.ReadByte(seekPointer);
while (b != 0)
{
bytes.Add(b);
seekPointer = (IntPtr)(seekPointer.ToInt64() + sizeof(byte));
b = Marshal.ReadByte(seekPointer);
}
return Encoding.UTF8.GetString(bytes.ToArray());
}
catch (Exception e)
{
throw new Exception("Failed to retrieve lobby data for key " + pchKey + ": " + e.Message + "\n" + e.StackTrace, e);
}
}
// bool
@@ -269,12 +294,21 @@ namespace SteamNative
// bool
public bool SetLobbyData( CSteamID steamIDLobby /*class CSteamID*/, string pchKey /*const char **/, string pchValue /*const char **/ )
{
return platform.ISteamMatchmaking_SetLobbyData( steamIDLobby.Value, pchKey, pchValue );
}
// void
public void SetLobbyGameServer( CSteamID steamIDLobby /*class CSteamID*/, uint unGameServerIP /*uint32*/, ushort unGameServerPort /*uint16*/, CSteamID steamIDGameServer /*class CSteamID*/ )
{
byte[] pchKeyBytes = Encoding.UTF8.GetBytes(pchKey + "\0");
byte[] pchValueBytes = Encoding.UTF8.GetBytes(pchValue + "\0");
GCHandle handleKey = GCHandle.Alloc(pchKeyBytes, GCHandleType.Pinned);
GCHandle handleValue = GCHandle.Alloc(pchValueBytes, GCHandleType.Pinned);
bool retVal = platform.ISteamMatchmaking_SetLobbyData(steamIDLobby.Value, handleKey.AddrOfPinnedObject(), handleValue.AddrOfPinnedObject());
handleKey.Free(); handleValue.Free();
return retVal;
}
// void
public void SetLobbyGameServer( CSteamID steamIDLobby /*class CSteamID*/, uint unGameServerIP /*uint32*/, ushort unGameServerPort /*uint16*/, CSteamID steamIDGameServer /*class CSteamID*/ )
{
platform.ISteamMatchmaking_SetLobbyGameServer( steamIDLobby.Value, unGameServerIP, unGameServerPort, steamIDGameServer.Value );
}