fixed bug with lifetime hit ratio causing erroneous ban

ip lookup on profile shows error if failed
truncate chat messages over 50 characters
removed html raw on client messages :c
show client rank colors on server overview if authorized
break long messages on profile page
prevent masked status showing up to non privileged users in webfront
This commit is contained in:
RaidMax 2018-03-28 22:01:09 -05:00
parent 233aeeb12f
commit 9db8ad80ef
9 changed files with 36 additions and 21 deletions

View File

@ -271,7 +271,8 @@ if (totalChestKills >= 250)
double chestAbdomenRatioLerpValueForFlag = Thresholds.Lerp(Thresholds.ChestAbdomenRatioThresholdLowSample(2.25), Thresholds.ChestAbdomenRatioThresholdHighSample(2.25), lerpAmount) + marginOfError;
double chestAbdomenLerpValueForBan = Thresholds.Lerp(Thresholds.ChestAbdomenRatioThresholdLowSample(3.0), Thresholds.ChestAbdomenRatioThresholdHighSample(3.0), lerpAmount) + marginOfError;
double currentChestAbdomenRatio = HitLocationCount[IW4Info.HitLocation.torso_upper] / (double)HitLocationCount[IW4Info.HitLocation.torso_lower];
double currentChestAbdomenRatio = stats.HitLocations.Single(hl => hl.Location == IW4Info.HitLocation.torso_upper).HitCount /
stats.HitLocations.Single(hl => hl.Location == IW4Info.HitLocation.torso_lower).HitCount;
if (currentChestAbdomenRatio > chestAbdomenRatioLerpValueForFlag)
{
@ -284,8 +285,8 @@ if (totalChestKills >= 250)
Log.WriteDebug($"**Ratio {currentChestAbdomenRatio}");
Log.WriteDebug($"**MaxRatio {chestAbdomenLerpValueForBan}");
var sb = new StringBuilder();
foreach (var kvp in HitLocationCount)
sb.Append($"HitLocation: {kvp.Key} -> {kvp.Value}\r\n");
foreach (var location in stats.HitLocations)
sb.Append($"HitLocation: {location.Location} -> {location.HitCount}\r\n");
Log.WriteDebug(sb.ToString());
// Log.WriteDebug($"ThresholdReached: {AboveThresholdCount}");
@ -305,8 +306,8 @@ if (totalChestKills >= 250)
Log.WriteDebug($"**Ratio {currentChestAbdomenRatio}");
Log.WriteDebug($"**MaxRatio {chestAbdomenRatioLerpValueForFlag}");
var sb = new StringBuilder();
foreach (var kvp in HitLocationCount)
sb.Append($"HitLocation: {kvp.Key} -> {kvp.Value}\r\n");
foreach (var location in stats.HitLocations)
sb.Append($"HitLocation: {location.Location} -> {location.HitCount}\r\n");
Log.WriteDebug(sb.ToString());
// Log.WriteDebug($"ThresholdReached: {AboveThresholdCount}");

View File

@ -42,7 +42,7 @@ namespace StatsPlugin.Models
[NotMapped]
public float AverageHitOffset
{
get => (float)Math.Round(HitLocations.Sum(c => c.HitOffsetAverage) / HitLocations.Where(c => c.HitOffsetAverage > 0).Count(), 4);
get => (float)Math.Round(HitLocations.Sum(c => c.HitOffsetAverage) / Math.Max(1, HitLocations.Where(c => c.HitOffsetAverage > 0).Count()), 4);
}
[NotMapped]
public int SessionKills { get; set; }

View File

@ -129,7 +129,7 @@ namespace StatsPlugin
(double)clientStats.Where(c => c.HitLocations.Count > 0)
.Sum(c => c.HitLocations.Where(hl => hl.Location != IW4Info.HitLocation.none).Sum(f => f.HitCount)), 2);
hitOffsetAverage = clientStats.Sum(c => c.AverageHitOffset) / clientStats.Where(c => c.AverageHitOffset > 0).Count();
hitOffsetAverage = clientStats.Sum(c => c.AverageHitOffset) / Math.Max(1, clientStats.Where(c => c.AverageHitOffset > 0).Count());
}
return new List<ProfileMeta>()

View File

@ -45,7 +45,7 @@ namespace WebfrontCore.Controllers
var administeredPenaltiesMeta = await Manager.GetPenaltyService()
.ReadGetClientPenaltiesAsync(client.ClientId, false);
if (client.Level > SharedLibrary.Objects.Player.Permission.Trusted)
if (Authorized && client.Level > SharedLibrary.Objects.Player.Permission.Trusted)
clientDto.Meta.Add(new ProfileMeta()
{
Key = "Masked",

View File

@ -30,7 +30,8 @@ namespace WebfrontCore.Controllers
Players = s.Players.Where(p => p != null).Select(p => new PlayerInfo
{
Name = p.Name,
ClientId = p.ClientId
ClientId = p.ClientId,
Level = p.Level.ToString()
}).ToList(),
ChatHistory = s.ChatHistory.OrderBy(c => c.Time).Take((int)Math.Ceiling(s.ClientNum / 2.0)).ToArray(),
PlayerHistory = s.PlayerHistory.ToArray()

View File

@ -8,7 +8,7 @@
@{
for (int i = 0; i < Model.ChatHistory.Length; i++)
{
string message = "&ndash; " + @Model.ChatHistory[i].Message;
string message = @Model.ChatHistory[i].Message;
if (Model.ChatHistory[i].Message == "CONNECTED")
{
<span class="text-light"><span class="oi oi-account-login mr-2 text-success"> </span>@Model.ChatHistory[i].Name</span><br />
@ -20,7 +20,7 @@
}
if (Model.ChatHistory[i].Message != "CONNECTED" && Model.ChatHistory[i].Message != "DISCONNECTED")
{
<span class="text-light">@Model.ChatHistory[i].Name</span><span> @Html.Raw(@message) </span><br />
<span class="text-light">@Model.ChatHistory[i].Name</span><span> &mdash; @message.Substring(0, Math.Min(50, message.Length - 1)) </span><br />
}
}
}
@ -31,7 +31,8 @@
@{
for (int i = 0; i < half; i++)
{
<span>@Html.ActionLink(Model.Players[i].Name, "ProfileAsync", "Client", new { id = Model.Players[i].ClientId })</span><br />
string levelColorClass = !ViewBag.Authorized ? "" : $"level-color-{Model.Players[i].Level.ToLower()}";
<span>@Html.ActionLink(Model.Players[i].Name, "ProfileAsync", "Client", new { id = Model.Players[i].ClientId }, new { @class=levelColorClass })</span><br />
}
}
</div>
@ -39,7 +40,8 @@
@{
for (int i = half; i < Model.ClientCount; i++)
{
<span>@Html.ActionLink(Model.Players[i].Name, "ProfileAsync", "Client", new { id = Model.Players[i].ClientId })</span><br />
string levelColorClass = !ViewBag.Authorized ? "" : $"level-color-{Model.Players[i].Level.ToLower()}";
<span>@Html.ActionLink(Model.Players[i].Name, "ProfileAsync", "Client", new { id = Model.Players[i].ClientId }, new { @class = levelColorClass })</span><br />
}
}
</div>

View File

@ -46,6 +46,7 @@
</nav>
</header>
<!-- Main Modal -->
<div class="modal fade" id="mainModal" tabindex="-1" role="dialog" aria-labelledby="mainModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content bg-dark">
@ -60,6 +61,7 @@
</div>
</div>
</div>
<!-- End Main Modal -->
<!-- Action Modal -->
<div class="modal fade" id="actionModal" tabindex="-1" role="dialog" aria-labelledby="actionModalLabel" aria-hidden="true">

View File

@ -3,14 +3,14 @@
}
.level-color-user, .level-color-guest {
color: rgba(255, 255, 255, 0.85);
color: rgba(255, 255, 255, 0.7);
}
.level-bgcolor-user, .level-bgcolor-guest {
background-color: rgba(255, 255, 255, 0.85);
}
.level-color-trusted, .level-color-user {
.level-color-trusted {
color: rgba(116,147,99,1);
}
@ -158,3 +158,7 @@
.profile-action:hover {
opacity: 0.75;
}
#profile_events span {
word-break: break-all;
}

View File

@ -57,12 +57,17 @@ $(document).ready(function () {
const ip = $(this).data("ip");
$.getJSON("http://ip-api.com/json/" + ip)
.done(function (response) {
$('.modal-title').text(ip);
$('.modal-body').text("");
$('.modal-body').append("ASN &mdash; " + response["as"] + "<br/>");
$('.modal-body').append("ISP &mdash; " + response["isp"] + "<br/>");
$('.modal-body').append("Organization &mdash; " + response["org"] + "<br/>");
$('.modal-body').append("Location &mdash; " + response["city"] + ", " + response["regionName"] + ", " + response["country"] + "<br/>");
$('#mainModal .modal-title').text(ip);
$('#mainModal .modal-body').text("");
$('#mainModal .modal-body').append("ASN &mdash; " + response["as"] + "<br/>");
$('#mainModal .modal-body').append("ISP &mdash; " + response["isp"] + "<br/>");
$('#mainModal .modal-body').append("Organization &mdash; " + response["org"] + "<br/>");
$('#mainModal .modal-body').append("Location &mdash; " + response["city"] + ", " + response["regionName"] + ", " + response["country"] + "<br/>");
$('#mainModal').modal();
})
.fail(function (jqxhr, textStatus, error) {
$('#mainModal .modal-title').text("Error");
$('#mainModal .modal-body').html('<span class="text-danger">&mdash;'+ error + '</span>');
$('#mainModal').modal();
});
});