fixed ping bug showing origin ping instead of target
event parser has GetGameDir made parsers choosen more dynamically profile shows online/offline status of client
This commit is contained in:
parent
cd2bbfb3d4
commit
2964fd71b2
@ -104,5 +104,8 @@ namespace Application.EventParsers
|
|||||||
Owner = server
|
Owner = server
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// other parsers can derive from this parser so we make it virtual
|
||||||
|
public virtual string GetGameDir() => "userraw";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
Application/EventParsers/IW5EventParser.cs
Normal file
12
Application/EventParsers/IW5EventParser.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using SharedLibraryCore.Interfaces;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Application.EventParsers
|
||||||
|
{
|
||||||
|
class IW5EventParser : IW4EventParser
|
||||||
|
{
|
||||||
|
public override string GetGameDir() => "rzodemo";
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using SharedLibraryCore;
|
using SharedLibraryCore;
|
||||||
@ -88,5 +89,7 @@ namespace Application.EventParsers
|
|||||||
Owner = server
|
Owner = server
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetGameDir() => $"t6r{Path.DirectorySeparatorChar}data";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,9 +89,6 @@ namespace Application.RconParsers
|
|||||||
long npID = Regex.Match(responseLine, @"([a-z]|[0-9]){16}", RegexOptions.IgnoreCase).Value.ConvertLong();
|
long npID = Regex.Match(responseLine, @"([a-z]|[0-9]){16}", RegexOptions.IgnoreCase).Value.ConvertLong();
|
||||||
int.TryParse(playerInfo[0], out cID);
|
int.TryParse(playerInfo[0], out cID);
|
||||||
var regex = Regex.Match(responseLine, @"\d+\.\d+\.\d+.\d+\:\d{1,5}");
|
var regex = Regex.Match(responseLine, @"\d+\.\d+\.\d+.\d+\:\d{1,5}");
|
||||||
#if DEBUG
|
|
||||||
Ping = 1;
|
|
||||||
#endif
|
|
||||||
int cIP = regex.Value.Split(':')[0].ConvertToIP();
|
int cIP = regex.Value.Split(':')[0].ConvertToIP();
|
||||||
regex = Regex.Match(responseLine, @"[0-9]{1,2}\s+[0-9]+\s+");
|
regex = Regex.Match(responseLine, @"[0-9]{1,2}\s+[0-9]+\s+");
|
||||||
int score = Int32.Parse(regex.Value.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[1]);
|
int score = Int32.Parse(regex.Value.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[1]);
|
||||||
|
@ -17,6 +17,7 @@ using IW4MAdmin.Application.Misc;
|
|||||||
using Application.RconParsers;
|
using Application.RconParsers;
|
||||||
using Application.EventParsers;
|
using Application.EventParsers;
|
||||||
using SharedLibraryCore.Exceptions;
|
using SharedLibraryCore.Exceptions;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace IW4MAdmin
|
namespace IW4MAdmin
|
||||||
{
|
{
|
||||||
@ -573,13 +574,20 @@ namespace IW4MAdmin
|
|||||||
public async Task Initialize()
|
public async Task Initialize()
|
||||||
{
|
{
|
||||||
RconParser = ServerConfig.UseT6MParser ? (IRConParser)new T6MRConParser() : new IW4RConParser();
|
RconParser = ServerConfig.UseT6MParser ? (IRConParser)new T6MRConParser() : new IW4RConParser();
|
||||||
EventParser = ServerConfig.UseT6MParser ? (IEventParser)new T6MEventParser() : new IW4EventParser();
|
|
||||||
|
|
||||||
var version = await this.GetDvarAsync<string>("version");
|
var version = await this.GetDvarAsync<string>("version");
|
||||||
GameName = Utilities.GetGame(version.Value);
|
GameName = Utilities.GetGame(version.Value);
|
||||||
|
|
||||||
if (GameName == Game.UKN)
|
if (GameName == Game.IW4)
|
||||||
|
EventParser = new IW4EventParser();
|
||||||
|
else if (GameName == Game.IW5)
|
||||||
|
EventParser = new IW5EventParser();
|
||||||
|
else if (GameName == Game.T6M)
|
||||||
|
EventParser = new T6MEventParser();
|
||||||
|
else if (GameName == Game.UKN)
|
||||||
Logger.WriteWarning($"Game name not recognized: {version}");
|
Logger.WriteWarning($"Game name not recognized: {version}");
|
||||||
|
else
|
||||||
|
EventParser = new IW4EventParser();
|
||||||
|
|
||||||
var shortversion = await this.GetDvarAsync<string>("shortversion");
|
var shortversion = await this.GetDvarAsync<string>("shortversion");
|
||||||
var hostname = await this.GetDvarAsync<string>("sv_hostname");
|
var hostname = await this.GetDvarAsync<string>("sv_hostname");
|
||||||
@ -617,7 +625,7 @@ namespace IW4MAdmin
|
|||||||
Website = website.Value;
|
Website = website.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (SharedLibraryCore.Exceptions.DvarException)
|
catch (DvarException)
|
||||||
{
|
{
|
||||||
Website = "this server's website";
|
Website = "this server's website";
|
||||||
}
|
}
|
||||||
@ -643,19 +651,21 @@ namespace IW4MAdmin
|
|||||||
}
|
}
|
||||||
|
|
||||||
CustomCallback = await ScriptLoaded();
|
CustomCallback = await ScriptLoaded();
|
||||||
|
string mainPath = EventParser.GetGameDir();
|
||||||
string mainPath = (GameName == Game.IW4 && onelog.Value >= 0) ? "userraw" : "main";
|
mainPath = (GameName == Game.IW4 && onelog.Value > 0) ? "main" : mainPath;
|
||||||
// patch for T5M:V2 log path
|
|
||||||
mainPath = (GameName == Game.T5M) ? "rzodemo" : mainPath;
|
|
||||||
// patch for T6M:PLUTONIUM
|
|
||||||
mainPath = (GameName == Game.T6M) ? $"t6r{Path.DirectorySeparatorChar}data" : mainPath;
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
// basepath.Value = @"\\192.168.88.253\Call of Duty Black Ops II";
|
// basepath.Value = @"\\192.168.88.253\Call of Duty Black Ops II";
|
||||||
#endif
|
#endif
|
||||||
string logPath = (game.Value == "" || onelog?.Value == 1) ?
|
string logPath = game.Value == string.Empty ?
|
||||||
$"{basepath.Value.Replace('\\', Path.DirectorySeparatorChar)}{Path.DirectorySeparatorChar}{mainPath}{Path.DirectorySeparatorChar}{logfile.Value}" :
|
$"{basepath.Value.Replace('\\', Path.DirectorySeparatorChar)}{Path.DirectorySeparatorChar}{mainPath}{Path.DirectorySeparatorChar}{logfile.Value}" :
|
||||||
$"{basepath.Value.Replace('\\', Path.DirectorySeparatorChar)}{Path.DirectorySeparatorChar}{game.Value.Replace('/', Path.DirectorySeparatorChar)}{Path.DirectorySeparatorChar}{logfile.Value}";
|
$"{basepath.Value.Replace('\\', Path.DirectorySeparatorChar)}{Path.DirectorySeparatorChar}{game.Value.Replace('/', Path.DirectorySeparatorChar)}{Path.DirectorySeparatorChar}{logfile.Value}";
|
||||||
|
|
||||||
|
// hopefully fix wine drive name mangling
|
||||||
|
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
|
{
|
||||||
|
logPath = Regex.Replace(logPath, @"[A-Z]:", "");
|
||||||
|
}
|
||||||
|
|
||||||
if (!File.Exists(logPath))
|
if (!File.Exists(logPath))
|
||||||
{
|
{
|
||||||
Logger.WriteError($"Gamelog {logPath} does not exist!");
|
Logger.WriteError($"Gamelog {logPath} does not exist!");
|
||||||
|
@ -1090,14 +1090,14 @@ namespace SharedLibraryCore.Commands
|
|||||||
if (E.Target == null)
|
if (E.Target == null)
|
||||||
await E.Owner.Broadcast($"{E.Origin.Name}'s ping is ^5{E.Origin.Ping}^7ms");
|
await E.Owner.Broadcast($"{E.Origin.Name}'s ping is ^5{E.Origin.Ping}^7ms");
|
||||||
else
|
else
|
||||||
await E.Owner.Broadcast($"{E.Target.Name}'s ping is ^5{E.Origin.Ping}^7ms");
|
await E.Owner.Broadcast($"{E.Target.Name}'s ping is ^5{E.Target.Ping}^7ms");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (E.Target == null)
|
if (E.Target == null)
|
||||||
await E.Origin.Tell($"Your ping is ^5{E.Origin.Ping}^7ms");
|
await E.Origin.Tell($"Your ping is ^5{E.Origin.Ping}^7ms");
|
||||||
else
|
else
|
||||||
await E.Origin.Tell($"{E.Target.Name}'s ping is ^5{E.Origin.Ping}^7ms");
|
await E.Origin.Tell($"{E.Target.Name}'s ping is ^5{E.Target.Ping}^7ms");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,5 +22,7 @@ namespace SharedLibraryCore.Dtos
|
|||||||
public string TimePlayed { get; set; }
|
public string TimePlayed { get; set; }
|
||||||
public bool Authenticated { get; set; }
|
public bool Authenticated { get; set; }
|
||||||
public List<ProfileMeta> Meta { get; set; }
|
public List<ProfileMeta> Meta { get; set; }
|
||||||
|
public bool Online { get; set; }
|
||||||
|
public string TimeOnline { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,17 @@ namespace SharedLibraryCore.Interfaces
|
|||||||
{
|
{
|
||||||
public interface IEventParser
|
public interface IEventParser
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Generates a game event based on log line input
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="server">server the event occurred on</param>
|
||||||
|
/// <param name="logLine">single log line string</param>
|
||||||
|
/// <returns></returns>
|
||||||
GameEvent GetEvent(Server server, string logLine);
|
GameEvent GetEvent(Server server, string logLine);
|
||||||
|
/// <summary>
|
||||||
|
/// Get game specific folder prefix for log files
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Game directory prefix</returns>
|
||||||
|
string GetGameDir();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,8 @@ namespace WebfrontCore.Controllers
|
|||||||
.Distinct()
|
.Distinct()
|
||||||
.OrderBy(i => i)
|
.OrderBy(i => i)
|
||||||
.ToList(),
|
.ToList(),
|
||||||
|
Online = Manager.GetActiveClients().FirstOrDefault(c => c.ClientId == client.ClientId) != null,
|
||||||
|
TimeOnline = (DateTime.UtcNow - client.LastConnection).TimeSpanText()
|
||||||
};
|
};
|
||||||
|
|
||||||
var meta = await MetaService.GetMeta(client.ClientId);
|
var meta = await MetaService.GetMeta(client.ClientId);
|
||||||
|
@ -11,6 +11,15 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="profile_info" class="text-center text-sm-left pr-3 pl-3">
|
<div id="profile_info" class="text-center text-sm-left pr-3 pl-3">
|
||||||
<div id="profile_name">
|
<div id="profile_name">
|
||||||
|
@if (Model.Online)
|
||||||
|
{
|
||||||
|
<span class="oi oi-media-record text-success pr-2 h4" title="Online for @Model.TimeOnline"></span>
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<span class="oi oi-media-record text-danger pr-2 h4" title="Offline"></span>
|
||||||
|
}
|
||||||
<div class="client-name h1 d-flex d-inline-flex">
|
<div class="client-name h1 d-flex d-inline-flex">
|
||||||
@Model.Name
|
@Model.Name
|
||||||
</div>
|
</div>
|
||||||
@ -21,13 +30,13 @@
|
|||||||
<div id="profile_aliases_btn" class="oi oi-caret-bottom h3 ml-0 ml-md-2"></div>
|
<div id="profile_aliases_btn" class="oi oi-caret-bottom h3 ml-0 ml-md-2"></div>
|
||||||
|
|
||||||
@if (Model.LevelInt < (int)ViewBag.User.Level &&
|
@if (Model.LevelInt < (int)ViewBag.User.Level &&
|
||||||
(SharedLibraryCore.Objects.Player.Permission)Model.LevelInt != SharedLibraryCore.Objects.Player.Permission.Banned)
|
(SharedLibraryCore.Objects.Player.Permission)Model.LevelInt != SharedLibraryCore.Objects.Player.Permission.Banned)
|
||||||
{
|
{
|
||||||
<div id="profile_action_ban_btn" class="profile-action oi oi-lock-unlocked text-success h3 ml-2" title="Ban Client" data-action="ban" aria-hidden="true"></div>
|
<div id="profile_action_ban_btn" class="profile-action oi oi-lock-unlocked text-success h3 ml-2" title="Ban Client" data-action="ban" aria-hidden="true"></div>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (Model.LevelInt < (int)ViewBag.User.Level &&
|
@if (Model.LevelInt < (int)ViewBag.User.Level &&
|
||||||
(SharedLibraryCore.Objects.Player.Permission)Model.LevelInt == SharedLibraryCore.Objects.Player.Permission.Banned)
|
(SharedLibraryCore.Objects.Player.Permission)Model.LevelInt == SharedLibraryCore.Objects.Player.Permission.Banned)
|
||||||
{
|
{
|
||||||
<div id="profile_action_unban_btn" class="profile-action oi oi-lock-locked text-danger h3 ml-2" title="Unban Client" data-action="unban" aria-hidden="true"></div>
|
<div id="profile_action_unban_btn" class="profile-action oi oi-lock-locked text-danger h3 ml-2" title="Unban Client" data-action="unban" aria-hidden="true"></div>
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user