mirror of
https://github.com/simtactics/mysimulation.git
synced 2025-07-04 21:50:35 -04:00
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:
parent
f12ba1502b
commit
22191ce648
591 changed files with 53264 additions and 3362 deletions
22
server/FSO.Server.Database/DA/Outfits/DbOutfit.cs
Executable file
22
server/FSO.Server.Database/DA/Outfits/DbOutfit.cs
Executable file
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
|
||||
namespace FSO.Server.Database.DA.Outfits
|
||||
{
|
||||
public class DbOutfit
|
||||
{
|
||||
public uint outfit_id { get; set; }
|
||||
public Nullable<uint> avatar_owner { get; set; }
|
||||
public Nullable<uint> object_owner { get; set; }
|
||||
public ulong asset_id { get; set; }
|
||||
public int sale_price { get; set; }
|
||||
public int purchase_price { get; set; }
|
||||
public byte outfit_type { get; set; }
|
||||
public DbOutfitSource outfit_source { get; set; }
|
||||
}
|
||||
|
||||
public enum DbOutfitSource
|
||||
{
|
||||
cas,
|
||||
rack
|
||||
}
|
||||
}
|
16
server/FSO.Server.Database/DA/Outfits/IOutfits.cs
Executable file
16
server/FSO.Server.Database/DA/Outfits/IOutfits.cs
Executable file
|
@ -0,0 +1,16 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace FSO.Server.Database.DA.Outfits
|
||||
{
|
||||
public interface IOutfits
|
||||
{
|
||||
uint Create(DbOutfit outfit);
|
||||
List<DbOutfit> GetByObjectId(uint object_id);
|
||||
List<DbOutfit> GetByAvatarId(uint avatar_id);
|
||||
|
||||
bool UpdatePrice(uint outfit_id, uint object_id, int new_price);
|
||||
bool ChangeOwner(uint outfit_id, uint object_owner, uint new_avatar_owner);
|
||||
bool DeleteFromObject(uint outfit_id, uint object_id);
|
||||
bool DeleteFromAvatar(uint outfit_id, uint avatar_id);
|
||||
}
|
||||
}
|
64
server/FSO.Server.Database/DA/Outfits/SqlOutfits.cs
Executable file
64
server/FSO.Server.Database/DA/Outfits/SqlOutfits.cs
Executable file
|
@ -0,0 +1,64 @@
|
|||
using Dapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace FSO.Server.Database.DA.Outfits
|
||||
{
|
||||
public class SqlOutfits : AbstractSqlDA, IOutfits
|
||||
{
|
||||
public SqlOutfits(ISqlContext context) : base(context){
|
||||
}
|
||||
|
||||
public uint Create(DbOutfit outfit)
|
||||
{
|
||||
try {
|
||||
return (uint)Context.Connection.Query<int>("INSERT INTO fso_outfits (avatar_owner, object_owner, asset_id, sale_price, purchase_price, outfit_type, outfit_source) " +
|
||||
" VALUES (@avatar_owner, @object_owner, @asset_id, @sale_price, @purchase_price, @outfit_type, @outfit_source); " +
|
||||
" SELECT LAST_INSERT_ID();"
|
||||
, new {
|
||||
avatar_owner = outfit.avatar_owner,
|
||||
object_owner = outfit.object_owner,
|
||||
asset_id = outfit.asset_id,
|
||||
sale_price = outfit.sale_price,
|
||||
purchase_price = outfit.purchase_price,
|
||||
outfit_type = outfit.outfit_type,
|
||||
outfit_source = outfit.outfit_source.ToString()
|
||||
}).First();
|
||||
}catch(Exception ex){
|
||||
return uint.MaxValue;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ChangeOwner(uint outfit_id, uint object_owner, uint new_avatar_owner)
|
||||
{
|
||||
return Context.Connection.Execute("UPDATE fso_outfits SET avatar_owner = @avatar_owner, object_owner = NULL WHERE outfit_id = @outfit_id and object_owner = @object_owner", new { outfit_id = outfit_id, object_owner = object_owner, avatar_owner = new_avatar_owner }) > 0;
|
||||
}
|
||||
|
||||
public bool UpdatePrice(uint outfit_id, uint object_owner, int new_price)
|
||||
{
|
||||
return Context.Connection.Execute("UPDATE fso_outfits SET sale_price = @sale_price WHERE outfit_id = @outfit_id AND object_owner = @object_owner", new { outfit_id = outfit_id, object_owner = object_owner, sale_price = new_price }) > 0;
|
||||
}
|
||||
|
||||
public bool DeleteFromObject(uint outfit_id, uint object_id)
|
||||
{
|
||||
return Context.Connection.Execute("DELETE FROM fso_outfits WHERE outfit_id = @outfit_id AND object_owner = @object_owner", new { outfit_id = outfit_id, object_owner = object_id }) > 0;
|
||||
}
|
||||
|
||||
public bool DeleteFromAvatar(uint outfit_id, uint avatar_id)
|
||||
{
|
||||
return Context.Connection.Execute("DELETE FROM fso_outfits WHERE outfit_id = @outfit_id AND avatar_owner = @avatar_owner", new { outfit_id = outfit_id, avatar_owner = avatar_id }) > 0;
|
||||
}
|
||||
|
||||
public List<DbOutfit> GetByAvatarId(uint avatar_id)
|
||||
{
|
||||
return Context.Connection.Query<DbOutfit>("SELECT * FROM fso_outfits WHERE avatar_owner = @avatar_id", new { avatar_id = avatar_id }).ToList();
|
||||
}
|
||||
|
||||
public List<DbOutfit> GetByObjectId(uint object_id)
|
||||
{
|
||||
return Context.Connection.Query<DbOutfit>("SELECT * FROM fso_outfits WHERE object_owner = @object_id", new { object_id = object_id }).ToList();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue