1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-10 15:20:48 -05:00

remove create proxy as it's not even used anymore

more fixes for alias stuff
hopefully fix rare bug where client activity cshtml loop goes oob
add URLProtocol format to event parsers to allow connecting through webfront
This commit is contained in:
RaidMax
2019-04-06 21:48:49 -05:00
parent b14a80b9b0
commit 15a0be3035
18 changed files with 86 additions and 128 deletions

View File

@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace SharedLibraryCore.Database.Models
{
public class EFAlias : SharedEntity
public partial class EFAlias : SharedEntity
{
[Key]
public int AliasId { get; set; }

View File

@ -11,19 +11,10 @@ namespace SharedLibraryCore.Helpers
{
DateTime t = DateTime.UtcNow;
When = new DateTime(t.Year, t.Month, t.Day, t.Hour, Math.Min(59, UpdateInterval * (int)Math.Round(t.Minute / (float)UpdateInterval)), 0);
PlayerCount = cNum;
y = cNum;
}
#if DEBUG
public PlayerHistory(DateTime t, int cNum)
{
When = new DateTime(t.Year, t.Month, t.Day, t.Hour, Math.Min(59, UpdateInterval * (int)Math.Round(t.Minute / (float)UpdateInterval)), 0);
PlayerCount = cNum;
}
#endif
private DateTime When;
private int PlayerCount;
/// <summary>
/// Used by CanvasJS as a point on the x axis
@ -36,16 +27,9 @@ namespace SharedLibraryCore.Helpers
}
}
/// <summary>
/// Used by CanvasJS as a point on the y axis
/// </summary>
public int y
{
get
{
return PlayerCount;
}
}
public int y { get; }
}
}

View File

@ -27,5 +27,10 @@ namespace SharedLibraryCore.Interfaces
/// specifies the game name (usually the internal studio iteration ie: IW4, T5 etc...)
/// </summary>
Game GameName { get; set; }
/// <summary>
/// specifies the connect URI used to join game servers via web browser
/// </summary>
string URLProtocolFormat { get; set; }
}
}

View File

@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SharedLibraryCore.Objects
{
public class Alias : Database.Models.EFAlias
{
}
}

View File

@ -0,0 +1,7 @@
namespace SharedLibraryCore.Database.Models
{
public partial class EFAlias
{
}
}

View File

@ -80,13 +80,12 @@ namespace SharedLibraryCore.Database.Models
{
{ "_reportCount", 0 }
};
CurrentAlias = new EFAlias();
ReceivedPenalties = new List<EFPenalty>();
}
public override string ToString()
{
return $"{Name}::{NetworkId}";
return $"{CurrentAlias?.Name ?? "--"}::{NetworkId}";
}
/// <summary>

View File

@ -17,27 +17,6 @@ namespace SharedLibraryCore.Services
public async Task<EFAlias> Create(EFAlias entity)
{
throw await Task.FromResult(new Exception());
/*using (var context = new DatabaseContext())
{
var alias = new EFAlias()
{
Active = true,
DateAdded = DateTime.UtcNow,
IPAddress = entity.IPAddress,
Name = entity.Name
};
entity.Link = await context.AliasLinks
.FirstAsync(a => a.AliasLinkId == entity.Link.AliasLinkId);
context.Aliases.Add(entity);
await context.SaveChangesAsync();
return entity;
}*/
}
public Task<EFAlias> CreateProxy()
{
return null;
}
public async Task<EFAlias> Delete(EFAlias entity)

View File

@ -28,9 +28,12 @@ namespace SharedLibraryCore.Services
if (existingAlias != null)
{
entity.CurrentServer.Logger.WriteDebug($"[create] client with new GUID {entity} has existing link {existingAlias.LinkId}");
linkId = existingAlias.LinkId;
if (existingAlias.Name == entity.Name)
{
entity.CurrentServer.Logger.WriteDebug($"[create] client with new GUID {entity} has existing alias {existingAlias.AliasId}");
aliasId = existingAlias.AliasId;
}
}
@ -44,9 +47,12 @@ namespace SharedLibraryCore.Services
NetworkId = entity.NetworkId
};
context.Clients.Add(client);
// they're just using a new GUID
if (aliasId.HasValue)
{
entity.CurrentServer.Logger.WriteDebug($"[create] setting {entity}'s alias id and linkid to ({aliasId.Value}, {linkId.Value})");
client.CurrentAliasId = aliasId.Value;
client.AliasLinkId = linkId.Value;
}
@ -54,8 +60,9 @@ namespace SharedLibraryCore.Services
// link was found but they don't have an exact alias
else if (!aliasId.HasValue && linkId.HasValue)
{
entity.CurrentServer.Logger.WriteDebug($"[create] setting {entity}'s linkid to {linkId.Value}, but creating new alias");
client.AliasLinkId = linkId.Value;
client.CurrentAlias = new Alias()
client.CurrentAlias = new EFAlias()
{
Name = entity.Name,
DateAdded = DateTime.UtcNow,
@ -67,18 +74,22 @@ namespace SharedLibraryCore.Services
// brand new players (supposedly)
else
{
client.AliasLink = new EFAliasLink();
client.CurrentAlias = new Alias()
entity.CurrentServer.Logger.WriteDebug($"[create] creating new Link and Alias for {entity}");
var link = new EFAliasLink();
var alias = new EFAlias()
{
Name = entity.Name,
DateAdded = DateTime.UtcNow,
IPAddress = entity.IPAddress,
Link = client.AliasLink,
Link = link
};
link.Children.Add(alias);
client.AliasLink = link;
client.CurrentAlias = alias;
}
context.Clients.Add(client);
await context.SaveChangesAsync();
return client;
@ -474,11 +485,6 @@ namespace SharedLibraryCore.Services
.CountAsync();
}
}
public Task<EFClient> CreateProxy()
{
throw new NotImplementedException();
}
#endregion
}
}

View File

@ -68,11 +68,6 @@ namespace SharedLibraryCore.Services
return newEntity;
}
public Task<EFPenalty> CreateProxy()
{
throw new NotImplementedException();
}
public Task<EFPenalty> Delete(EFPenalty entity)
{
throw new NotImplementedException();

View File

@ -8,7 +8,6 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
@ -716,6 +715,20 @@ namespace SharedLibraryCore
return Assembly.GetCallingAssembly().GetName().Version.ToString();
}
public static string FormatExt(this string input, params object[] values)
{
var matches = Regex.Matches(Regex.Unescape(input), @"{{\w+}}");
string output = input;
int index = 0;
foreach (Match match in matches)
{
output = output.Replace(match.Value.ToString(), $"{{{index.ToString()}}}");
index++;
}
return string.Format(output, values);
}
#if DEBUG == true
private static readonly TypeInfo QueryCompilerTypeInfo = typeof(QueryCompiler).GetTypeInfo();