Removed NioTSO client and server

- NioTSO client isn't needed because we're using RayLib
- Added FreeSO's API server to handle most backend operations
This commit is contained in:
Tony Bark 2024-05-01 02:55:43 -04:00
parent f12ba1502b
commit 22191ce648
591 changed files with 53264 additions and 3362 deletions

View file

@ -0,0 +1,17 @@
namespace FSO.Server.Database.DA.AvatarClaims
{
public class DbAvatarClaim
{
public int avatar_claim_id { get; set; }
public uint avatar_id { get; set; }
public string owner { get; set; }
public uint location { get; set; }
}
public class DbAvatarActive
{
public uint avatar_id { get; set; }
public string name { get; set; }
public byte privacy_mode { get; set; }
public uint location { get; set; }
}
}

View file

@ -0,0 +1,21 @@
using System.Collections.Generic;
namespace FSO.Server.Database.DA.AvatarClaims
{
public interface IAvatarClaims
{
DbAvatarClaim Get(int id);
IEnumerable<DbAvatarClaim> GetAll();
IEnumerable<DbAvatarActive> GetAllActiveAvatars();
int? GetAllActiveAvatarsCount();
DbAvatarClaim GetByAvatarID(uint id);
IEnumerable<DbAvatarClaim> GetAllByOwner(string owner);
int? TryCreate(DbAvatarClaim claim);
bool Claim(int id, string previousOwner, string newOwner, uint location);
void RemoveRemaining(string previousOwner, uint location);
void Delete(int id, string owner);
void DeleteAll(string owner);
}
}

View file

@ -0,0 +1,84 @@
using Dapper;
using MySql.Data.MySqlClient;
using System.Collections.Generic;
using System.Linq;
namespace FSO.Server.Database.DA.AvatarClaims
{
public class SqlAvatarClaims : AbstractSqlDA, IAvatarClaims
{
public SqlAvatarClaims(ISqlContext context) : base(context)
{
}
public bool Claim(int id, string previousOwner, string newOwner, uint location)
{
try
{
Context.Connection.Query("UPDATE fso_avatar_claims SET owner = @owner, location = @location WHERE avatar_claim_id = @claim_id AND owner = @previous_owner", new { claim_id = (int)id, previous_owner = previousOwner, owner = newOwner, location = location });
var newClaim = Context.Connection.Query<DbAvatarClaim>("SELECT * FROM fso_avatar_claims WHERE avatar_claim_id = @claim_id AND owner = @owner", new { claim_id = (int)id, owner = newOwner }).FirstOrDefault();
return newClaim != null;
}
catch (MySqlException ex)
{
return false;
}
}
public void RemoveRemaining(string previousOwner, uint location)
{
Context.Connection.Query("DELETE FROM fso_avatar_claims WHERE location = @location AND owner = @previous_owner", new { previous_owner = previousOwner, location = location });
}
public void Delete(int id, string owner)
{
Context.Connection.Query("DELETE FROM fso_avatar_claims WHERE owner = @owner AND avatar_claim_id = @claim_id", new { owner = owner, claim_id = (int)id });
}
public void DeleteAll(string owner)
{
Context.Connection.Query("DELETE FROM fso_avatar_claims WHERE owner = @owner", new { owner = owner });
}
public DbAvatarClaim Get(int id)
{
return Context.Connection.Query<DbAvatarClaim>("SELECT * FROM fso_avatar_claims WHERE avatar_claim_id = @claim_id", new { claim_id = (int)id }).FirstOrDefault();
}
public IEnumerable<DbAvatarClaim> GetAll()
{
return Context.Connection.Query<DbAvatarClaim>("SELECT * FROM fso_avatar_claims");
}
public IEnumerable<DbAvatarActive> GetAllActiveAvatars()
{
return Context.Connection.Query<DbAvatarActive>("SELECT b.*, a.location FROM fso.fso_avatar_claims as a "+
"inner join fso.fso_avatars as b ON a.avatar_id = b.avatar_id;");
}
public int? GetAllActiveAvatarsCount()
{
return Context.Connection.Query<int>("SELECT COUNT(*) FROM fso_avatar_claims").FirstOrDefault();
}
public DbAvatarClaim GetByAvatarID(uint id)
{
return Context.Connection.Query<DbAvatarClaim>("SELECT * FROM fso_avatar_claims WHERE avatar_id = @id", new { id = id }).FirstOrDefault();
}
public IEnumerable<DbAvatarClaim> GetAllByOwner(string owner)
{
return Context.Connection.Query<DbAvatarClaim>("SELECT * FROM fso_avatar_claims WHERE owner = @owner", new { owner = owner });
}
public int? TryCreate(DbAvatarClaim claim)
{
try
{
return Context.Connection.Query<int>("INSERT INTO fso_avatar_claims (avatar_id, owner, location) " +
" VALUES (@avatar_id, @owner, @location); SELECT LAST_INSERT_ID();", claim).First();
}
catch (MySqlException ex)
{
return null;
}
}
}
}