38f1ddb...178a853: v0.8.9.1, removed content folder

This commit is contained in:
Joonas Rikkonen
2019-03-18 19:46:58 +02:00
parent 38f1ddb6fe
commit 6c0679c297
1054 changed files with 151673 additions and 144931 deletions
@@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Facepunch.Steamworks
{
public class ServerAuth
{
internal Server server;
/// <summary>
/// Steamid, Ownerid, Status
/// </summary>
public Action<ulong, ulong, Status> OnAuthChange;
/// <summary>
/// Steam authetication statuses
/// </summary>
public enum Status : int
{
OK = 0,
UserNotConnectedToSteam = 1,
NoLicenseOrExpired = 2,
VACBanned = 3,
LoggedInElseWhere = 4,
VACCheckTimedOut = 5,
AuthTicketCanceled = 6,
AuthTicketInvalidAlreadyUsed = 7,
AuthTicketInvalid = 8,
PublisherIssuedBan = 9,
}
internal ServerAuth( Server s )
{
server = s;
server.RegisterCallback<SteamNative.ValidateAuthTicketResponse_t>( OnAuthTicketValidate );
}
void OnAuthTicketValidate( SteamNative.ValidateAuthTicketResponse_t data )
{
if ( OnAuthChange != null )
OnAuthChange( data.SteamID, data.OwnerSteamID, (Status) data.AuthSessionResponse );
}
/// <summary>
/// Start authorizing a ticket. This user isn't authorized yet. Wait for a call to OnAuthChange.
/// </summary>
public unsafe bool StartSession( byte[] data, ulong steamid )
{
fixed ( byte* p = data )
{
var result = server.native.gameServer.BeginAuthSession( (IntPtr)p, data.Length, steamid );
if ( result == SteamNative.BeginAuthSessionResult.OK )
return true;
return false;
}
}
/// <summary>
/// Forget this guy. They're no longer in the game.
/// </summary>
public void EndSession( ulong steamid )
{
server.native.gameServer.EndAuthSession( steamid );
}
}
}
@@ -0,0 +1,88 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
namespace Facepunch.Steamworks
{
/// <summary>
/// If you're manually processing the server queries, you should use this class.
/// </summary>
public class ServerQuery
{
internal Server server;
internal static byte[] buffer = new byte[64*1024];
internal ServerQuery( Server s )
{
server = s;
}
/// <summary>
/// A server query packet.
/// </summary>
public struct Packet
{
/// <summary>
/// Target IP address
/// </summary>
public uint Address { get; internal set; }
/// <summary>
/// Target port
/// </summary>
public ushort Port { get; internal set; }
/// <summary>
/// This data is pooled. Make a copy if you don't use it immediately.
/// This buffer is also quite large - so pay attention to Size.
/// </summary>
public byte[] Data { get; internal set; }
/// <summary>
/// Size of the data
/// </summary>
public int Size { get; internal set; }
}
/// <summary>
/// If true, Steam wants to send a packet. You should respond by sending
/// this packet in an unconnected way to the returned Address and Port.
/// </summary>
/// <param name="packet">Packet to send. The Data passed is pooled - so use it immediately.</param>
/// <returns>True if we want to send a packet</returns>
public unsafe bool GetOutgoingPacket( out Packet packet )
{
packet = new Packet();
fixed ( byte* ptr = buffer )
{
uint addr = 0;
ushort port = 0;
var size = server.native.gameServer.GetNextOutgoingPacket( (IntPtr)ptr, buffer.Length, out addr, out port );
if ( size == 0 )
return false;
packet.Size = size;
packet.Data = buffer;
packet.Address = addr;
packet.Port = port;
return true;
}
}
/// <summary>
/// We have received a server query on our game port. Pass it to Steam to handle.
/// </summary>
public unsafe void Handle( byte[] data, int size, uint address, ushort port )
{
fixed ( byte* ptr = data )
{
server.native.gameServer.HandleIncomingPacket( (IntPtr)ptr, size, address, port );
}
}
}
}
@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Runtime.InteropServices;
using System.Text;
namespace Facepunch.Steamworks
{
/// <summary>
/// Used to set up the server.
/// The variables in here are all required to be set, and can't be changed once the server is created.
/// </summary>
public class ServerInit
{
public IPAddress IpAddress;
public ushort SteamPort;
public ushort GamePort = 27015;
public ushort QueryPort = 27016;
public bool Secure = true;
/// <summary>
/// The version string is usually in the form x.x.x.x, and is used by the master server to detect when the server is out of date.
/// If you go into the dedicated server tab on steamworks you'll be able to server the latest version. If this version number is
/// less than that latest version then your server won't show.
/// </summary>
public string VersionString = "1.0.0.0";
/// <summary>
/// This should be the same directory game where gets installed into. Just the folder name, not the whole path. I.e. "Rust", "Garrysmod".
/// </summary>
public string ModDir = "unset";
/// <summary>
/// The game description. Setting this to the full name of your game is recommended.
/// </summary>
public string GameDescription = "unset";
public ServerInit( string modDir, string gameDesc )
{
ModDir = modDir;
GameDescription = gameDesc;
}
/// <summary>
/// Set the Steam quert port
/// </summary>
public ServerInit RandomSteamPort()
{
SteamPort = (ushort)new Random().Next( 10000, 60000 );
return this;
}
/// <summary>
/// If you pass MASTERSERVERUPDATERPORT_USEGAMESOCKETSHARE into usQueryPort, then it causes the game server API to use
/// "GameSocketShare" mode, which means that the game is responsible for sending and receiving UDP packets for the master
/// server updater.
///
/// More info about this here: https://partner.steamgames.com/doc/api/ISteamGameServer#HandleIncomingPacket
/// </summary>
public ServerInit QueryShareGamePort()
{
QueryPort = 0xFFFF;
return this;
}
}
}
@@ -0,0 +1,146 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
namespace Facepunch.Steamworks
{
/// <summary>
/// Allows getting and setting stats on users from the gameserver. These stats
/// should have been set up on the Steamworks website for your app.
/// </summary>
public class ServerStats
{
internal Server server;
internal ServerStats( Server s )
{
server = s;
}
[StructLayout( LayoutKind.Sequential )]
public struct StatsReceived
{
public int Result;
public ulong SteamId;
}
/// <summary>
/// Retrieve the stats for this user. If you pass a callback function in
/// this will be called when the stats are recieved, the bool will signify whether
/// it was successful or not.
/// </summary>
public void Refresh( ulong steamid, Action<ulong, bool> Callback = null )
{
if ( Callback == null )
{
server.native.gameServerStats.RequestUserStats( steamid );
return;
}
server.native.gameServerStats.RequestUserStats( steamid, ( o, failed ) =>
{
Callback( steamid, o.Result == SteamNative.Result.OK && !failed );
} );
}
/// <summary>
/// Once you've set a stat change on a user you need to commit your changes.
/// You can do that using this function. The callback will let you know if
/// your action succeeded, but most of the time you can fire and forget.
/// </summary>
public void Commit( ulong steamid, Action<ulong, bool> Callback = null )
{
if ( Callback == null )
{
server.native.gameServerStats.StoreUserStats( steamid );
return;
}
server.native.gameServerStats.StoreUserStats( steamid, ( o, failed ) =>
{
Callback( steamid, o.Result == SteamNative.Result.OK && !failed );
} );
}
/// <summary>
/// Set the named stat for this user. Setting stats should follow the rules
/// you defined in Steamworks.
/// </summary>
public bool SetInt( ulong steamid, string name, int stat )
{
return server.native.gameServerStats.SetUserStat( steamid, name, stat );
}
/// <summary>
/// Set the named stat for this user. Setting stats should follow the rules
/// you defined in Steamworks.
/// </summary>
public bool SetFloat( ulong steamid, string name, float stat )
{
return server.native.gameServerStats.SetUserStat0( steamid, name, stat );
}
/// <summary>
/// Get the named stat for this user. If getting the stat failed, will return
/// defaultValue. You should have called Refresh for this userid - which downloads
/// the stats from the backend. If you didn't call it this will always return defaultValue.
/// </summary>
public int GetInt( ulong steamid, string name, int defaultValue = 0 )
{
int data = defaultValue;
if ( !server.native.gameServerStats.GetUserStat( steamid, name, out data ) )
return defaultValue;
return data;
}
/// <summary>
/// Get the named stat for this user. If getting the stat failed, will return
/// defaultValue. You should have called Refresh for this userid - which downloads
/// the stats from the backend. If you didn't call it this will always return defaultValue.
/// </summary>
public float GetFloat( ulong steamid, string name, float defaultValue = 0 )
{
float data = defaultValue;
if ( !server.native.gameServerStats.GetUserStat0( steamid, name, out data ) )
return defaultValue;
return data;
}
/// <summary>
/// Unlocks the specified achievement for the specified user. Must have called Refresh on a steamid first.
/// Remember to use Commit after use.
/// </summary>
public bool SetAchievement( ulong steamid, string name )
{
return server.native.gameServerStats.SetUserAchievement( steamid, name );
}
/// <summary>
/// Resets the unlock status of an achievement for the specified user. Must have called Refresh on a steamid first.
/// Remember to use Commit after use.
/// </summary>
public bool ClearAchievement( ulong steamid, string name )
{
return server.native.gameServerStats.ClearUserAchievement( steamid, name );
}
/// <summary>
/// Return true if available, exists and unlocked
/// </summary>
public bool GetAchievement( ulong steamid, string name )
{
bool achieved = false;
if ( !server.native.gameServerStats.GetUserAchievement( steamid, name, ref achieved ) )
return false;
return achieved;
}
}
}