fix issue with restarting via web
replace some hard coded string in javascript with localization break things to fix things
This commit is contained in:
parent
5f588bb0f7
commit
0b0290a871
@ -104,7 +104,6 @@ namespace IW4MAdmin.Application.EventParsers
|
||||
Type = GameEvent.EventType.Command,
|
||||
Data = message,
|
||||
Origin = new EFClient() { NetworkId = originId },
|
||||
Target = Utilities.IW4MAdminClient(),
|
||||
Message = message
|
||||
};
|
||||
}
|
||||
@ -114,7 +113,6 @@ namespace IW4MAdmin.Application.EventParsers
|
||||
Type = GameEvent.EventType.Say,
|
||||
Data = message,
|
||||
Origin = new EFClient() { NetworkId = originId },
|
||||
Target = Utilities.IW4MAdminClient(),
|
||||
Message = message
|
||||
};
|
||||
}
|
||||
@ -166,8 +164,6 @@ namespace IW4MAdmin.Application.EventParsers
|
||||
|
||||
if (regexMatch.Success)
|
||||
{
|
||||
bool isBot = regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().Contains("bot");
|
||||
|
||||
return new GameEvent()
|
||||
{
|
||||
Type = GameEvent.EventType.PreConnect,
|
||||
@ -181,9 +177,7 @@ namespace IW4MAdmin.Application.EventParsers
|
||||
NetworkId = regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertGuidToLong(),
|
||||
ClientNumber = Convert.ToInt32(regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginClientNumber]].ToString()),
|
||||
State = EFClient.ClientState.Connecting,
|
||||
IsBot = isBot
|
||||
},
|
||||
Target = Utilities.IW4MAdminClient()
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -206,8 +200,7 @@ namespace IW4MAdmin.Application.EventParsers
|
||||
NetworkId = regexMatch.Groups[Configuration.Quit.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertGuidToLong(),
|
||||
ClientNumber = Convert.ToInt32(regexMatch.Groups[Configuration.Quit.GroupMapping[ParserRegex.GroupType.OriginClientNumber]].ToString()),
|
||||
State = EFClient.ClientState.Disconnecting
|
||||
},
|
||||
Target = Utilities.IW4MAdminClient()
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -244,8 +237,7 @@ namespace IW4MAdmin.Application.EventParsers
|
||||
{
|
||||
Type = GameEvent.EventType.JoinTeam,
|
||||
Data = logLine,
|
||||
Origin = new EFClient() { NetworkId = lineSplit[1].ConvertGuidToLong() },
|
||||
Target = Utilities.IW4MAdminClient()
|
||||
Origin = new EFClient() { NetworkId = lineSplit[1].ConvertGuidToLong() }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -57,13 +57,13 @@ namespace IW4MAdmin.Application.IO
|
||||
try
|
||||
{
|
||||
var gameEvent = Parser.GenerateGameEvent(eventLine);
|
||||
// we don't want to add the even if ignoreBots is on and the event comes froma bot
|
||||
if (!ignoreBots.Value || (ignoreBots.Value && (gameEvent.Origin.NetworkId != -1 || gameEvent.Target.NetworkId != -1)))
|
||||
// we don't want to add the event if ignoreBots is on and the event comes from a bot
|
||||
if (!ignoreBots.Value || (ignoreBots.Value && !((gameEvent.Origin?.IsBot ?? false) || (gameEvent.Target?.IsBot ?? false))))
|
||||
{
|
||||
gameEvent.Owner = server;
|
||||
// we need to pull the "live" versions of the client (only if the client id isn't IW4MAdmin
|
||||
gameEvent.Origin = gameEvent.Origin.ClientId == 1 ? gameEvent.Origin : server.GetClientsAsList().First(_client => _client.NetworkId == gameEvent.Origin.NetworkId);
|
||||
gameEvent.Target = gameEvent.Target.ClientId == 1 ? gameEvent.Target : server.GetClientsAsList().First(_client => _client.NetworkId == gameEvent.Target.NetworkId);
|
||||
// we need to pull the "live" versions of the client (only if the client id isn't IW4MAdmin)
|
||||
gameEvent.Origin = gameEvent.Origin == null || gameEvent.Origin.NetworkId == 1 ? gameEvent.Origin : server.GetClientsAsList().First(_client => _client.NetworkId == gameEvent.Origin.NetworkId);
|
||||
gameEvent.Target = gameEvent.Target == null || gameEvent.Target.NetworkId == 1 ? gameEvent.Target : server.GetClientsAsList().First(_client => _client.NetworkId == gameEvent.Target.NetworkId);
|
||||
|
||||
events.Add(gameEvent);
|
||||
}
|
||||
@ -74,6 +74,7 @@ namespace IW4MAdmin.Application.IO
|
||||
if (!ignoreBots.Value)
|
||||
{
|
||||
server.Logger.WriteWarning("Could not find client in client list when parsing event line");
|
||||
server.Logger.WriteDebug(eventLine);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,13 +61,13 @@ namespace IW4MAdmin.Application.IO
|
||||
try
|
||||
{
|
||||
var gameEvent = Parser.GenerateGameEvent(eventLine);
|
||||
// we don't want to add the even if ignoreBots is on and the event comes froma bot
|
||||
if (!ignoreBots.Value || (ignoreBots.Value && (gameEvent.Origin.NetworkId != -1 || gameEvent.Target.NetworkId != -1)))
|
||||
// we don't want to add the event if ignoreBots is on and the event comes from a bot
|
||||
if (!ignoreBots.Value || (ignoreBots.Value && !((gameEvent.Origin?.IsBot ?? false) || (gameEvent.Target?.IsBot ?? false))))
|
||||
{
|
||||
gameEvent.Owner = server;
|
||||
// we need to pull the "live" versions of the client (only if the client id isn't IW4MAdmin
|
||||
gameEvent.Origin = gameEvent.Origin.ClientId == 1 ? gameEvent.Origin : server.GetClientsAsList().First(_client => _client.NetworkId == gameEvent.Origin.NetworkId);
|
||||
gameEvent.Target = gameEvent.Target.ClientId == 1 ? gameEvent.Target : server.GetClientsAsList().First(_client => _client.NetworkId == gameEvent.Target.NetworkId);
|
||||
// we need to pull the "live" versions of the client (only if the client id isn't IW4MAdmin)
|
||||
gameEvent.Origin = gameEvent.Origin == null || gameEvent.Origin.NetworkId == 1 ? gameEvent.Origin : server.GetClientsAsList().First(_client => _client.NetworkId == gameEvent.Origin.NetworkId);
|
||||
gameEvent.Target = gameEvent.Target == null || gameEvent.Target.NetworkId == 1 ? gameEvent.Target : server.GetClientsAsList().First(_client => _client.NetworkId == gameEvent.Target.NetworkId);
|
||||
|
||||
events.Add(gameEvent);
|
||||
}
|
||||
@ -81,6 +81,7 @@ namespace IW4MAdmin.Application.IO
|
||||
if (!ignoreBots.Value)
|
||||
{
|
||||
server.Logger.WriteWarning("Could not find client in client list when parsing event line");
|
||||
server.Logger.WriteDebug(eventLine);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,8 +38,6 @@ namespace IW4MAdmin
|
||||
{
|
||||
Logger.WriteDebug($"Client slot #{clientFromLog.ClientNumber} now reserved");
|
||||
|
||||
try
|
||||
{
|
||||
EFClient client = await Manager.GetClientService().GetUnique(clientFromLog.NetworkId);
|
||||
|
||||
// first time client is connecting to server
|
||||
@ -61,7 +59,6 @@ namespace IW4MAdmin
|
||||
|
||||
// Do the player specific stuff
|
||||
client.ClientNumber = clientFromLog.ClientNumber;
|
||||
client.IsBot = clientFromLog.IsBot;
|
||||
client.Score = clientFromLog.Score;
|
||||
client.Ping = clientFromLog.Ping;
|
||||
client.CurrentServer = this;
|
||||
@ -82,13 +79,6 @@ namespace IW4MAdmin
|
||||
client.State = ClientState.Connected;
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.WriteError($"{loc["SERVER_ERROR_ADDPLAYER"]} {clientFromLog}");
|
||||
Logger.WriteError(ex.GetExceptionInfo());
|
||||
}
|
||||
}
|
||||
|
||||
override public async Task OnClientDisconnected(EFClient client)
|
||||
{
|
||||
#if DEBUG == true
|
||||
@ -229,7 +219,19 @@ namespace IW4MAdmin
|
||||
#endif
|
||||
// we can go ahead and put them in so that they don't get re added
|
||||
Clients[E.Origin.ClientNumber] = E.Origin;
|
||||
try
|
||||
{
|
||||
await OnClientConnected(E.Origin);
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.WriteError($"{loc["SERVER_ERROR_ADDPLAYER"]} {E.Origin}");
|
||||
Logger.WriteDebug(ex.GetExceptionInfo());
|
||||
|
||||
Clients[E.Origin.ClientNumber] = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
ChatHistory.Add(new ChatInfo()
|
||||
{
|
||||
|
@ -2,6 +2,7 @@
|
||||
using SharedLibraryCore;
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IW4MAdmin.Application
|
||||
@ -112,14 +113,19 @@ namespace IW4MAdmin.Application
|
||||
WebfrontCore.Program.Init(ServerManager, ServerManager.CancellationToken) :
|
||||
Task.CompletedTask;
|
||||
|
||||
// we want to run this one on a manual thread instead of letting the thread pool handle it,
|
||||
// because we can't exit early from waiting on console input, and it prevents us from restarting
|
||||
var inputThread = new Thread(async () => await ReadConsoleInput());
|
||||
inputThread.Start();
|
||||
|
||||
var tasks = new[]
|
||||
{
|
||||
ServerManager.Start(),
|
||||
webfrontTask,
|
||||
ReadConsoleInput(),
|
||||
};
|
||||
|
||||
await Task.WhenAll(tasks);
|
||||
inputThread.Abort();
|
||||
|
||||
ServerManager.Logger.WriteVerbose(Utilities.CurrentLocalization.LocalizationIndex["MANAGER_SHUTDOWN_SUCCESS"]);
|
||||
}
|
||||
|
@ -155,7 +155,6 @@ namespace IW4MAdmin.Application.RconParsers
|
||||
IPAddress = ip,
|
||||
Ping = ping,
|
||||
Score = score,
|
||||
IsBot = ip == null,
|
||||
State = EFClient.ClientState.Connecting
|
||||
};
|
||||
|
||||
|
@ -499,7 +499,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
|
||||
AttackerId = attacker.ClientId,
|
||||
VictimId = victim.ClientId,
|
||||
ServerId = serverId,
|
||||
Map = ParseEnum<IW4Info.MapName>.Get(map, typeof(IW4Info.MapName)),
|
||||
//Map = ParseEnum<IW4Info.MapName>.Get(map, typeof(IW4Info.MapName)),
|
||||
DeathOrigin = vDeathOrigin,
|
||||
KillOrigin = vKillOrigin,
|
||||
DeathType = ParseEnum<IW4Info.MeansOfDeath>.Get(type, typeof(IW4Info.MeansOfDeath)),
|
||||
@ -1230,24 +1230,6 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
|
||||
}
|
||||
|
||||
public static async Task<long> GetIdForServer(Server server)
|
||||
{
|
||||
// hack: my laziness
|
||||
if ($"{server.IP}:{server.GetPort().ToString()}" == "66.150.121.184:28965")
|
||||
{
|
||||
return 886229536;
|
||||
}
|
||||
|
||||
else if ($"{server.IP}:{server.GetPort().ToString()}" == "66.150.121.184:28960")
|
||||
{
|
||||
return 1645744423;
|
||||
}
|
||||
|
||||
else if ($"{server.IP}:{server.GetPort().ToString()}" == "66.150.121.184:28970")
|
||||
{
|
||||
return 1645809959;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
long id = HashCode.Combine(server.IP, server.GetPort());
|
||||
id = id < 0 ? Math.Abs(id) : id;
|
||||
@ -1270,4 +1252,3 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -471,7 +471,7 @@ namespace IW4MAdmin.Plugins.Stats
|
||||
/// <returns></returns>
|
||||
private bool ShouldIgnoreEvent(EFClient origin, EFClient target)
|
||||
{
|
||||
return ((origin.ClientId <= 1 && target.ClientId <= 1) || ((target.IsBot || origin.IsBot) && ServerManager.GetApplicationSettings().Configuration().IgnoreBots));
|
||||
return (origin.ClientId <= 1 && target.ClientId <= 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -712,7 +712,7 @@ namespace SharedLibraryCore.Database.Models
|
||||
[NotMapped]
|
||||
public int Score { get; set; }
|
||||
[NotMapped]
|
||||
public bool IsBot { get; set; }
|
||||
public bool IsBot => NetworkId == -1;
|
||||
|
||||
[NotMapped]
|
||||
public ClientState State { get; set; }
|
||||
|
@ -105,6 +105,7 @@ namespace WebfrontCore.Controllers
|
||||
ViewBag.SocialLink = SocialLink ?? "";
|
||||
ViewBag.SocialTitle = SocialTitle;
|
||||
ViewBag.Pages = Pages;
|
||||
ViewBag.Localization = Utilities.CurrentLocalization.LocalizationIndex;
|
||||
|
||||
base.OnActionExecuting(context);
|
||||
}
|
||||
|
@ -52,6 +52,9 @@ namespace WebfrontCore.Controllers
|
||||
|
||||
Manager.GetEventHandler().AddEvent(remoteEvent);
|
||||
List<CommandResponseInfo> response;
|
||||
|
||||
try
|
||||
{
|
||||
// wait for the event to process
|
||||
if (!(await remoteEvent.WaitAsync(Utilities.DefaultCommandTimeout, server.Manager.CancellationToken)).Failed)
|
||||
{
|
||||
@ -75,6 +78,19 @@ namespace WebfrontCore.Controllers
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
catch (System.OperationCanceledException)
|
||||
{
|
||||
response = new List<CommandResponseInfo>()
|
||||
{
|
||||
new CommandResponseInfo()
|
||||
{
|
||||
ClientId = client.ClientId,
|
||||
Response = Utilities.CurrentLocalization.LocalizationIndex["COMMADS_RESTART_SUCCESS"]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return View("_Response", response);
|
||||
}
|
||||
|
@ -156,6 +156,13 @@
|
||||
<environment include="Production">
|
||||
<script type="text/javascript" src="~/js/global.min.js"></script>
|
||||
</environment>
|
||||
<script>
|
||||
let _localizationTmp = @Html.Raw(Json.Serialize(ViewBag.Localization));
|
||||
const _localization = [];
|
||||
$.each(_localizationTmp.set, function (key, value) {
|
||||
_localization[key] = value;
|
||||
});
|
||||
</script>
|
||||
@RenderSection("scripts", required: false)
|
||||
</body>
|
||||
</html>
|
@ -7,7 +7,7 @@
|
||||
}
|
||||
|
||||
if (command[0] !== '!') {
|
||||
$('#console_command_response').text('All commands must start with !').addClass('text-danger');
|
||||
$('#console_command_response').text(_localization['WEBFRONT_CONSOLE_COMMAND']).addClass('text-danger');
|
||||
return false;
|
||||
}
|
||||
showLoader();
|
||||
@ -20,7 +20,7 @@
|
||||
.fail(function (jqxhr, textStatus, error) {
|
||||
errorLoader();
|
||||
hideLoader();
|
||||
$('#console_command_response').text('Could not execute command: ' + error).addClass('text-danger');
|
||||
$('#console_command_response').text(_localization['WEBFRONT_CONSOLE_ERROR'] + error).addClass('text-danger');
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -29,10 +29,10 @@ if ($('#penalty_table').length === 1) {
|
||||
$('#penalty_filter_selection').change(function() {
|
||||
location = location.href.split('?')[0] + "?showOnly=" + $('#penalty_filter_selection').val();
|
||||
});
|
||||
|
||||
/*
|
||||
https://stackoverflow.com/questions/19731730/jquery-js-detect-users-scroll-attempt-without-any-window-overflow-to-scroll
|
||||
*/
|
||||
|
||||
$('html').bind('mousewheel DOMMouseScroll', function (e) {
|
||||
var delta = (e.originalEvent.wheelDelta || -e.originalEvent.detail);
|
||||
|
||||
@ -44,7 +44,6 @@ if ($('#penalty_table').length === 1) {
|
||||
/*
|
||||
https://stackoverflow.com/questions/3898130/check-if-a-user-has-scrolled-to-the-bottom
|
||||
*/
|
||||
|
||||
var _throttleTimer = null;
|
||||
var _throttleDelay = 100;
|
||||
var $window = $(window);
|
||||
|
@ -60,33 +60,33 @@
|
||||
$.getJSON('https://extreme-ip-lookup.com/json/' + ip)
|
||||
.done(function (response) {
|
||||
$('#mainModal .modal-title').text(ip);
|
||||
$('#mainModal .modal-body').text("");
|
||||
$('#mainModal .modal-body').text('');
|
||||
if (response.ipName.length > 0) {
|
||||
$('#mainModal .modal-body').append("Hostname — " + response.ipName + '<br/>');
|
||||
$('#mainModal .modal-body').append(`${_localization['WEBFRONT_PROFILE_LOOKUP_HOSTNAME']} — ${response.ipName}<br/>`);
|
||||
}
|
||||
if (response.isp.length > 0) {
|
||||
$('#mainModal .modal-body').append("ISP — " + response.isp + '<br/>');
|
||||
$('#mainModal .modal-body').append(`${_localization['WEBFRONT_PROFILE_LOOKUP_ISP']} — ${response.isp}<br/>`);
|
||||
}
|
||||
if (response.org.length > 0) {
|
||||
$('#mainModal .modal-body').append("Organization — " + response.org + '<br/>');
|
||||
$('#mainModal .modal-body').append(`${_localization['WEBFRONT_PROFILE_LOOKUP_ORG']} — ${response.org}<br/>`);
|
||||
}
|
||||
if (response['businessName'].length > 0) {
|
||||
$('#mainModal .modal-body').append("Business — " + response.businessName + '<br/>');
|
||||
$('#mainModal .modal-body').append(`${_localization['WEBFRONT_PROFILE_LOOKUP_BUSINESS']} — ${response.businessName}<br/>`);
|
||||
}
|
||||
if (response['businessWebsite'].length > 0) {
|
||||
$('#mainModal .modal-body').append("Website — " + response.businessWebsite + '<br/>');
|
||||
$('#mainModal .modal-body').append(`${_localization['WEBFRONT_PROFILE_LOOKUP_WEBSITE']} — ${response.businessWebsite}<br/>`);
|
||||
}
|
||||
if (response.city.length > 0 || response.region.length > 0 || response.country.length > 0) {
|
||||
$('#mainModal .modal-body').append("Location — ");
|
||||
$('#mainModal .modal-body').append(`${_localization['WEBFRONT_PROFILE_LOOKUP_LOCATION']} — `);
|
||||
}
|
||||
if (response.city.length > 0) {
|
||||
$('#mainModal .modal-body').append(response.city);
|
||||
}
|
||||
if (response.region.length > 0) {
|
||||
$('#mainModal .modal-body').append(', ' + response.region);
|
||||
$('#mainModal .modal-body').append((response.city.length > 0 ? ', ' : '') + response.region);
|
||||
}
|
||||
if (response.country.length > 0) {
|
||||
$('#mainModal .modal-body').append(', ' + response.country);
|
||||
$('#mainModal .modal-body').append((response.country.length > 0 ? ', ' : '') + response.country);
|
||||
}
|
||||
|
||||
$('#mainModal').modal();
|
||||
|
@ -84,7 +84,7 @@ function refreshClientActivity() {
|
||||
$('#server_clientactivity_' + serverId).html(response);
|
||||
})
|
||||
.fail(function (jqxhr, textStatus, error) {
|
||||
$('#server_clientactivity_' + serverId).html(" Could not load client activity - " + error);
|
||||
$('#server_clientactivity_' + serverId).html('');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -31,7 +31,7 @@
|
||||
}
|
||||
},
|
||||
title: {
|
||||
text: "Performance History",
|
||||
text: _localization['WEBFRONT_STATS_PERFORMANCE_HISTORY'],
|
||||
fontSize: 14
|
||||
},
|
||||
axisX: {
|
||||
@ -39,14 +39,14 @@
|
||||
lineThickness: 0,
|
||||
tickThickness: 0,
|
||||
margin: 0,
|
||||
valueFormatString: " ",
|
||||
valueFormatString: ' ',
|
||||
},
|
||||
axisY: {
|
||||
labelFontSize: 12,
|
||||
interval: interval,
|
||||
gridThickness: 0,
|
||||
lineThickness: 0.5,
|
||||
valueFormatString: "#,##0",
|
||||
valueFormatString: '#,##0',
|
||||
minimum: min,
|
||||
maximum: max
|
||||
},
|
||||
@ -54,7 +54,7 @@
|
||||
dockInsidePlotArea: true
|
||||
},
|
||||
data: [{
|
||||
type: "splineArea",
|
||||
type: 'splineArea',
|
||||
color: 'rgba(0, 122, 204, 0.25)',
|
||||
markerSize: 3.5,
|
||||
dataPoints: fixedData
|
||||
|
Loading…
Reference in New Issue
Block a user