Compare commits
186 Commits
2022.03.23
...
2022.10.12
Author | SHA1 | Date | |
---|---|---|---|
186db53bad | |||
40466f84c4 | |||
bdb5a1c5f8 | |||
5d9e2b3bf1 | |||
1cf99869f6 | |||
12da0f463b | |||
e88071684d | |||
cd6097d133 | |||
d5cf4451a2 | |||
1e1e8bbe7b | |||
dadd236069 | |||
2380f23dbe | |||
3cffdfdd9d | |||
400c5d1f4d | |||
ca35fbb19f | |||
809cb0b7f4 | |||
18f23fd07d | |||
7526f86dab | |||
527ffbaced | |||
6f086ac565 | |||
cf4dd6a868 | |||
3efafa24ff | |||
fe919251fb | |||
a67f7f9351 | |||
e99ca3c140 | |||
ccedb01e8d | |||
841bcf6156 | |||
b381af5fba | |||
444c06e65e | |||
561909158f | |||
cd12c3f26e | |||
c817f9a810 | |||
b27ae1517e | |||
507688a175 | |||
d2cfd50e39 | |||
51e8b31e42 | |||
fa1567d3f5 | |||
f97e266c24 | |||
506b17dbb3 | |||
bef8c08d90 | |||
b78c467539 | |||
c3e042521a | |||
cb5f490d3b | |||
0a55c54c42 | |||
f43f7b5040 | |||
540cf7489d | |||
1a72faee60 | |||
4e44bb5ea1 | |||
9e17bcc38f | |||
4b33b33d01 | |||
6f1bc7ab90 | |||
63e1774cb6 | |||
61df873bb1 | |||
052eeb0615 | |||
88e67747fe | |||
5db94723aa | |||
ea8216ecdf | |||
6abbcbe464 | |||
57484690b6 | |||
7a022a1973 | |||
7108e23a03 | |||
77d25890da | |||
2fca68a7ea | |||
a6c0a94f6c | |||
71abaac9e1 | |||
e07651b931 | |||
5a2ee36df9 | |||
2daa4991d1 | |||
775c0a91b5 | |||
55bccc7d3d | |||
4322e8d882 | |||
a92f9fc29c | |||
fbf424c77d | |||
b8e001fcfe | |||
5ab5b73ecf | |||
4534d24fe6 | |||
73c8d0da33 | |||
16d75470b5 | |||
f02552faa1 | |||
a4923d03f9 | |||
8ae6561f4e | |||
deeb1dea87 | |||
9ab34614c5 | |||
2cff25d6b3 | |||
df3e226dc9 | |||
ef3db63ba7 | |||
49fe4520ff | |||
6587187a34 | |||
b337e232a2 | |||
a44b4e9475 | |||
ffb0e5cac1 | |||
ecc2b5bf54 | |||
2ac9cc4379 | |||
215037095f | |||
5433d7d1d2 | |||
0446fe1ec5 | |||
cf2a00e5b3 | |||
ab494a22cb | |||
b690579154 | |||
acc967e50a | |||
c493fbe13d | |||
ee56a5db1f | |||
f235d0fafd | |||
7ecf516278 | |||
210f1ca336 | |||
a38789adb9 | |||
e459b2fcde | |||
26853a0005 | |||
ee14306db9 | |||
169105e849 | |||
7c10e0e3de | |||
2f7eb07e39 | |||
0f9f4f597b | |||
880f9333d9 | |||
31da5d352e | |||
83a469cae3 | |||
1f13f9122c | |||
dd8c4f438f | |||
2230036d45 | |||
1700b7da91 | |||
fab97ccad4 | |||
0bf0d033f7 | |||
2bbabcb9e8 | |||
1995dbd080 | |||
a3b94b50e3 | |||
bc38b36e4a | |||
e346aa037e | |||
389c687420 | |||
074e36413e | |||
104d9bdc4c | |||
c51d28937b | |||
ffa8a46feb | |||
91c46dbdd4 | |||
ff0d22c142 | |||
3ad4aa2196 | |||
d462892467 | |||
cabedb6f0b | |||
5b7f5160b2 | |||
0a8e415af8 | |||
7b3ddd58c6 | |||
ed1032415e | |||
35b43e7438 | |||
284c2e9726 | |||
fd049edb3f | |||
4884abee76 | |||
1df76b6ac3 | |||
4c42a1d511 | |||
27635a6dd3 | |||
0175425708 | |||
5e12bf60b5 | |||
2f10ca8599 | |||
62ec18309e | |||
87361bf3d7 | |||
dc45136077 | |||
21b0a7998d | |||
20b8f0b99a | |||
314ff96e71 | |||
d7c4f5452c | |||
3cb50635e5 | |||
4fbe0ee0ed | |||
4023ca37d4 | |||
425ec2621d | |||
15c3ca53e2 | |||
6097ca504c | |||
70cd01eafb | |||
a2d5e37c6f | |||
19bd47d0f4 | |||
dc97956bc3 | |||
89fdc00f9b | |||
039a05d9ad | |||
25fb5fdc14 | |||
1e67f6e86c | |||
7dbdf87728 | |||
180a4911bc | |||
31123d9a33 | |||
3cf0f54ceb | |||
eafd7cb530 | |||
770785e979 | |||
92d713d188 | |||
34e531ef8d | |||
724992ef33 | |||
557cc1614f | |||
f90cdbef16 | |||
a863f78678 | |||
c93f896bc5 | |||
ccc8316a2f |
1
.gitignore
vendored
1
.gitignore
vendored
@ -224,7 +224,6 @@ bootstrap-custom.min.css
|
||||
bootstrap-custom.css
|
||||
**/Master/static
|
||||
**/Master/dev_env
|
||||
/WebfrontCore/Views/Plugins/*
|
||||
/WebfrontCore/wwwroot/**/dds
|
||||
/WebfrontCore/wwwroot/images/radar/*
|
||||
|
||||
|
55
Application/Alerts/AlertExtensions.cs
Normal file
55
Application/Alerts/AlertExtensions.cs
Normal file
@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using SharedLibraryCore;
|
||||
using SharedLibraryCore.Alerts;
|
||||
using SharedLibraryCore.Database.Models;
|
||||
|
||||
namespace IW4MAdmin.Application.Alerts;
|
||||
|
||||
public static class AlertExtensions
|
||||
{
|
||||
public static Alert.AlertState BuildAlert(this EFClient client, Alert.AlertCategory? type = null)
|
||||
{
|
||||
return new Alert.AlertState
|
||||
{
|
||||
RecipientId = client.ClientId,
|
||||
Category = type ?? Alert.AlertCategory.Information
|
||||
};
|
||||
}
|
||||
|
||||
public static Alert.AlertState WithCategory(this Alert.AlertState state, Alert.AlertCategory category)
|
||||
{
|
||||
state.Category = category;
|
||||
return state;
|
||||
}
|
||||
|
||||
public static Alert.AlertState OfType(this Alert.AlertState state, string type)
|
||||
{
|
||||
state.Type = type;
|
||||
return state;
|
||||
}
|
||||
|
||||
public static Alert.AlertState WithMessage(this Alert.AlertState state, string message)
|
||||
{
|
||||
state.Message = message;
|
||||
return state;
|
||||
}
|
||||
|
||||
public static Alert.AlertState ExpiresIn(this Alert.AlertState state, TimeSpan expiration)
|
||||
{
|
||||
state.ExpiresAt = DateTime.Now.Add(expiration);
|
||||
return state;
|
||||
}
|
||||
|
||||
public static Alert.AlertState FromSource(this Alert.AlertState state, string source)
|
||||
{
|
||||
state.Source = source;
|
||||
return state;
|
||||
}
|
||||
|
||||
public static Alert.AlertState FromClient(this Alert.AlertState state, EFClient client)
|
||||
{
|
||||
state.Source = client.Name.StripColors();
|
||||
state.SourceId = client.ClientId;
|
||||
return state;
|
||||
}
|
||||
}
|
137
Application/Alerts/AlertManager.cs
Normal file
137
Application/Alerts/AlertManager.cs
Normal file
@ -0,0 +1,137 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using SharedLibraryCore.Alerts;
|
||||
using SharedLibraryCore.Configuration;
|
||||
using SharedLibraryCore.Database.Models;
|
||||
using SharedLibraryCore.Interfaces;
|
||||
|
||||
namespace IW4MAdmin.Application.Alerts;
|
||||
|
||||
public class AlertManager : IAlertManager
|
||||
{
|
||||
private readonly ApplicationConfiguration _appConfig;
|
||||
private readonly ConcurrentDictionary<int, List<Alert.AlertState>> _states = new();
|
||||
private readonly List<Func<Task<IEnumerable<Alert.AlertState>>>> _staticSources = new();
|
||||
|
||||
public AlertManager(ApplicationConfiguration appConfig)
|
||||
{
|
||||
_appConfig = appConfig;
|
||||
_states.TryAdd(0, new List<Alert.AlertState>());
|
||||
}
|
||||
|
||||
public EventHandler<Alert.AlertState> OnAlertConsumed { get; set; }
|
||||
|
||||
public async Task Initialize()
|
||||
{
|
||||
foreach (var source in _staticSources)
|
||||
{
|
||||
var alerts = await source();
|
||||
foreach (var alert in alerts)
|
||||
{
|
||||
AddAlert(alert);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Alert.AlertState> RetrieveAlerts(EFClient client)
|
||||
{
|
||||
lock (_states)
|
||||
{
|
||||
var alerts = Enumerable.Empty<Alert.AlertState>();
|
||||
if (client.Level > Data.Models.Client.EFClient.Permission.Trusted)
|
||||
{
|
||||
alerts = alerts.Concat(_states[0].Where(alert =>
|
||||
alert.MinimumPermission is null || alert.MinimumPermission <= client.Level));
|
||||
}
|
||||
|
||||
if (_states.ContainsKey(client.ClientId))
|
||||
{
|
||||
alerts = alerts.Concat(_states[client.ClientId].AsReadOnly());
|
||||
}
|
||||
|
||||
return alerts.OrderByDescending(alert => alert.OccuredAt);
|
||||
}
|
||||
}
|
||||
|
||||
public void MarkAlertAsRead(Guid alertId)
|
||||
{
|
||||
lock (_states)
|
||||
{
|
||||
foreach (var items in _states.Values)
|
||||
{
|
||||
var matchingEvent = items.FirstOrDefault(item => item.AlertId == alertId);
|
||||
|
||||
if (matchingEvent is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
items.Remove(matchingEvent);
|
||||
OnAlertConsumed?.Invoke(this, matchingEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void MarkAllAlertsAsRead(int recipientId)
|
||||
{
|
||||
lock (_states)
|
||||
{
|
||||
foreach (var items in _states.Values)
|
||||
{
|
||||
items.RemoveAll(item =>
|
||||
{
|
||||
if (item.RecipientId != null && item.RecipientId != recipientId)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
OnAlertConsumed?.Invoke(this, item);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AddAlert(Alert.AlertState alert)
|
||||
{
|
||||
lock (_states)
|
||||
{
|
||||
if (alert.RecipientId is null)
|
||||
{
|
||||
_states[0].Add(alert);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_states.ContainsKey(alert.RecipientId.Value))
|
||||
{
|
||||
_states[alert.RecipientId.Value] = new List<Alert.AlertState>();
|
||||
}
|
||||
|
||||
if (_appConfig.MinimumAlertPermissions.ContainsKey(alert.Type))
|
||||
{
|
||||
alert.MinimumPermission = _appConfig.MinimumAlertPermissions[alert.Type];
|
||||
}
|
||||
|
||||
_states[alert.RecipientId.Value].Add(alert);
|
||||
|
||||
PruneOldAlerts();
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterStaticAlertSource(Func<Task<IEnumerable<Alert.AlertState>>> alertSource)
|
||||
{
|
||||
_staticSources.Add(alertSource);
|
||||
}
|
||||
|
||||
|
||||
private void PruneOldAlerts()
|
||||
{
|
||||
foreach (var value in _states.Values)
|
||||
{
|
||||
value.RemoveAll(item => item.ExpiresAt < DateTime.UtcNow);
|
||||
}
|
||||
}
|
||||
}
|
@ -24,13 +24,14 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Jint" Version="3.0.0-beta-2037" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.1">
|
||||
<PackageReference Include="Jint" Version="3.0.0-beta-2038" />
|
||||
<PackageReference Include="MaxMind.GeoIP2" Version="5.1.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.8">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
|
||||
<PackageReference Include="RestEase" Version="1.5.5" />
|
||||
<PackageReference Include="RestEase" Version="1.5.7" />
|
||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
@ -63,6 +64,9 @@
|
||||
<None Update="Configuration\LoggingConfiguration.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Resources\GeoLite2-Country.mmdb">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
|
||||
|
@ -46,6 +46,8 @@ namespace IW4MAdmin.Application
|
||||
|
||||
public IList<IRConParser> AdditionalRConParsers { get; }
|
||||
public IList<IEventParser> AdditionalEventParsers { get; }
|
||||
public IList<Func<GameEvent, bool>> CommandInterceptors { get; set; } =
|
||||
new List<Func<GameEvent, bool>>();
|
||||
public ITokenAuthentication TokenAuthenticator { get; }
|
||||
public CancellationToken CancellationToken => _tokenSource.Token;
|
||||
public string ExternalIPAddress { get; private set; }
|
||||
@ -57,10 +59,11 @@ namespace IW4MAdmin.Application
|
||||
private readonly List<MessageToken> MessageTokens;
|
||||
private readonly ClientService ClientSvc;
|
||||
readonly PenaltyService PenaltySvc;
|
||||
private readonly IAlertManager _alertManager;
|
||||
public IConfigurationHandler<ApplicationConfiguration> ConfigHandler;
|
||||
readonly IPageList PageList;
|
||||
private readonly TimeSpan _throttleTimeout = new TimeSpan(0, 1, 0);
|
||||
private readonly CancellationTokenSource _tokenSource;
|
||||
private CancellationTokenSource _tokenSource;
|
||||
private readonly Dictionary<string, Task<IList>> _operationLookup = new Dictionary<string, Task<IList>>();
|
||||
private readonly ITranslationLookup _translationLookup;
|
||||
private readonly IConfigurationHandler<CommandConfiguration> _commandConfiguration;
|
||||
@ -82,18 +85,19 @@ namespace IW4MAdmin.Application
|
||||
IEnumerable<IPlugin> plugins, IParserRegexFactory parserRegexFactory, IEnumerable<IRegisterEvent> customParserEvents,
|
||||
IEventHandler eventHandler, IScriptCommandFactory scriptCommandFactory, IDatabaseContextFactory contextFactory,
|
||||
IMetaRegistration metaRegistration, IScriptPluginServiceResolver scriptPluginServiceResolver, ClientService clientService, IServiceProvider serviceProvider,
|
||||
ChangeHistoryService changeHistoryService, ApplicationConfiguration appConfig, PenaltyService penaltyService)
|
||||
ChangeHistoryService changeHistoryService, ApplicationConfiguration appConfig, PenaltyService penaltyService, IAlertManager alertManager)
|
||||
{
|
||||
MiddlewareActionHandler = actionHandler;
|
||||
_servers = new ConcurrentBag<Server>();
|
||||
MessageTokens = new List<MessageToken>();
|
||||
ClientSvc = clientService;
|
||||
PenaltySvc = penaltyService;
|
||||
_alertManager = alertManager;
|
||||
ConfigHandler = appConfigHandler;
|
||||
StartTime = DateTime.UtcNow;
|
||||
PageList = new PageList();
|
||||
AdditionalEventParsers = new List<IEventParser>() { new BaseEventParser(parserRegexFactory, logger, _appConfig) };
|
||||
AdditionalRConParsers = new List<IRConParser>() { new BaseRConParser(serviceProvider.GetRequiredService<ILogger<BaseRConParser>>(), parserRegexFactory) };
|
||||
AdditionalEventParsers = new List<IEventParser> { new BaseEventParser(parserRegexFactory, logger, _appConfig) };
|
||||
AdditionalRConParsers = new List<IRConParser> { new BaseRConParser(serviceProvider.GetRequiredService<ILogger<BaseRConParser>>(), parserRegexFactory) };
|
||||
TokenAuthenticator = new TokenAuthentication();
|
||||
_logger = logger;
|
||||
_tokenSource = new CancellationTokenSource();
|
||||
@ -508,6 +512,7 @@ namespace IW4MAdmin.Application
|
||||
#endregion
|
||||
|
||||
_metaRegistration.Register();
|
||||
await _alertManager.Initialize();
|
||||
|
||||
#region CUSTOM_EVENTS
|
||||
foreach (var customEvent in _customParserEvents.SelectMany(_events => _events.Events))
|
||||
@ -587,16 +592,30 @@ namespace IW4MAdmin.Application
|
||||
|
||||
public async Task Start() => await UpdateServerStates();
|
||||
|
||||
public void Stop()
|
||||
public async Task Stop()
|
||||
{
|
||||
foreach (var plugin in Plugins)
|
||||
{
|
||||
try
|
||||
{
|
||||
await plugin.OnUnloadAsync().WithTimeout(Utilities.DefaultCommandTimeout);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Could not cleanly unload plugin {PluginName}", plugin.Name);
|
||||
}
|
||||
}
|
||||
|
||||
_tokenSource.Cancel();
|
||||
|
||||
IsRunning = false;
|
||||
}
|
||||
|
||||
public void Restart()
|
||||
{
|
||||
IsRestartRequested = true;
|
||||
Stop();
|
||||
Stop().GetAwaiter().GetResult();
|
||||
_tokenSource = new CancellationTokenSource();
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
@ -618,7 +637,7 @@ namespace IW4MAdmin.Application
|
||||
|
||||
public EFClient FindActiveClient(EFClient client) => client.ClientNumber < 0 ?
|
||||
GetActiveClients()
|
||||
.FirstOrDefault(c => c.NetworkId == client.NetworkId) ?? client :
|
||||
.FirstOrDefault(c => c.NetworkId == client.NetworkId && c.GameName == client.GameName) ?? client :
|
||||
client;
|
||||
|
||||
public ClientService GetClientService()
|
||||
@ -684,5 +703,6 @@ namespace IW4MAdmin.Application
|
||||
}
|
||||
|
||||
public void RemoveCommandByName(string commandName) => _commands.RemoveAll(_command => _command.Name == commandName);
|
||||
public IAlertManager AlertManager => _alertManager;
|
||||
}
|
||||
}
|
||||
|
52
Application/Commands/AddClientNoteCommand.cs
Normal file
52
Application/Commands/AddClientNoteCommand.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Data.Models.Client;
|
||||
using IW4MAdmin.Application.Meta;
|
||||
using SharedLibraryCore;
|
||||
using SharedLibraryCore.Commands;
|
||||
using SharedLibraryCore.Configuration;
|
||||
using SharedLibraryCore.Dtos.Meta.Responses;
|
||||
using SharedLibraryCore.Interfaces;
|
||||
|
||||
namespace IW4MAdmin.Application.Commands;
|
||||
|
||||
public class AddClientNoteCommand : Command
|
||||
{
|
||||
private readonly IMetaServiceV2 _metaService;
|
||||
|
||||
public AddClientNoteCommand(CommandConfiguration config, ITranslationLookup layout, IMetaServiceV2 metaService) : base(config, layout)
|
||||
{
|
||||
Name = "addnote";
|
||||
Description = _translationLookup["COMMANDS_ADD_CLIENT_NOTE_DESCRIPTION"];
|
||||
Alias = "an";
|
||||
Permission = EFClient.Permission.Moderator;
|
||||
RequiresTarget = true;
|
||||
Arguments = new[]
|
||||
{
|
||||
new CommandArgument
|
||||
{
|
||||
Name = _translationLookup["COMMANDS_ARGS_PLAYER"],
|
||||
Required = true
|
||||
},
|
||||
new CommandArgument
|
||||
{
|
||||
Name = _translationLookup["COMMANDS_ARGS_NOTE"],
|
||||
Required = false
|
||||
}
|
||||
};
|
||||
|
||||
_metaService = metaService;
|
||||
}
|
||||
|
||||
public override async Task ExecuteAsync(GameEvent gameEvent)
|
||||
{
|
||||
var note = new ClientNoteMetaResponse
|
||||
{
|
||||
Note = gameEvent.Data?.Trim(),
|
||||
OriginEntityId = gameEvent.Origin.ClientId,
|
||||
ModifiedDate = DateTime.UtcNow
|
||||
};
|
||||
await _metaService.SetPersistentMetaValue("ClientNotes", note, gameEvent.Target.ClientId);
|
||||
gameEvent.Origin.Tell(_translationLookup["COMMANDS_ADD_CLIENT_NOTE_SUCCESS"]);
|
||||
}
|
||||
}
|
@ -1,11 +1,14 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Data.Abstractions;
|
||||
using Data.Models.Client;
|
||||
using Data.Models.Misc;
|
||||
using IW4MAdmin.Application.Alerts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SharedLibraryCore;
|
||||
using SharedLibraryCore.Alerts;
|
||||
using SharedLibraryCore.Configuration;
|
||||
using SharedLibraryCore.Interfaces;
|
||||
using ILogger = Microsoft.Extensions.Logging.ILogger;
|
||||
@ -16,10 +19,12 @@ namespace IW4MAdmin.Application.Commands
|
||||
{
|
||||
private readonly IDatabaseContextFactory _contextFactory;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IAlertManager _alertManager;
|
||||
private const short MaxLength = 1024;
|
||||
|
||||
public OfflineMessageCommand(CommandConfiguration config, ITranslationLookup layout,
|
||||
IDatabaseContextFactory contextFactory, ILogger<IDatabaseContextFactory> logger) : base(config, layout)
|
||||
IDatabaseContextFactory contextFactory, ILogger<IDatabaseContextFactory> logger, IAlertManager alertManager)
|
||||
: base(config, layout)
|
||||
{
|
||||
Name = "offlinemessage";
|
||||
Description = _translationLookup["COMMANDS_OFFLINE_MESSAGE_DESC"];
|
||||
@ -29,6 +34,51 @@ namespace IW4MAdmin.Application.Commands
|
||||
|
||||
_contextFactory = contextFactory;
|
||||
_logger = logger;
|
||||
_alertManager = alertManager;
|
||||
|
||||
_alertManager.RegisterStaticAlertSource(async () =>
|
||||
{
|
||||
var context = contextFactory.CreateContext(false);
|
||||
return await context.InboxMessages.Where(message => !message.IsDelivered)
|
||||
.Where(message => message.CreatedDateTime >= DateTime.UtcNow.AddDays(-7))
|
||||
.Where(message => message.DestinationClient.Level > EFClient.Permission.User)
|
||||
.Select(message => new Alert.AlertState
|
||||
{
|
||||
OccuredAt = message.CreatedDateTime,
|
||||
Message = message.Message,
|
||||
ExpiresAt = DateTime.UtcNow.AddDays(7),
|
||||
Category = Alert.AlertCategory.Message,
|
||||
Source = message.SourceClient.CurrentAlias.Name.StripColors(),
|
||||
SourceId = message.SourceClientId,
|
||||
RecipientId = message.DestinationClientId,
|
||||
ReferenceId = message.InboxMessageId,
|
||||
Type = nameof(EFInboxMessage)
|
||||
}).ToListAsync();
|
||||
});
|
||||
|
||||
_alertManager.OnAlertConsumed += (_, state) =>
|
||||
{
|
||||
if (state.Category != Alert.AlertCategory.Message || state.ReferenceId is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var context = contextFactory.CreateContext(true);
|
||||
foreach (var message in context.InboxMessages
|
||||
.Where(message => message.InboxMessageId == state.ReferenceId.Value).ToList())
|
||||
{
|
||||
message.IsDelivered = true;
|
||||
}
|
||||
|
||||
context.SaveChanges();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Could not update message state for alert {@Alert}", state);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public override async Task ExecuteAsync(GameEvent gameEvent)
|
||||
@ -47,14 +97,15 @@ namespace IW4MAdmin.Application.Commands
|
||||
|
||||
if (gameEvent.Target.IsIngame)
|
||||
{
|
||||
gameEvent.Origin.Tell(_translationLookup["COMMANDS_OFFLINE_MESSAGE_INGAME"].FormatExt(gameEvent.Target.Name));
|
||||
gameEvent.Origin.Tell(_translationLookup["COMMANDS_OFFLINE_MESSAGE_INGAME"]
|
||||
.FormatExt(gameEvent.Target.Name));
|
||||
return;
|
||||
}
|
||||
|
||||
await using var context = _contextFactory.CreateContext(enableTracking: false);
|
||||
var server = await context.Servers.FirstAsync(srv => srv.EndPoint == gameEvent.Owner.ToString());
|
||||
|
||||
var newMessage = new EFInboxMessage()
|
||||
var newMessage = new EFInboxMessage
|
||||
{
|
||||
SourceClientId = gameEvent.Origin.ClientId,
|
||||
DestinationClientId = gameEvent.Target.ClientId,
|
||||
@ -62,6 +113,12 @@ namespace IW4MAdmin.Application.Commands
|
||||
Message = gameEvent.Data,
|
||||
};
|
||||
|
||||
_alertManager.AddAlert(gameEvent.Target.BuildAlert(Alert.AlertCategory.Message)
|
||||
.WithMessage(gameEvent.Data.Trim())
|
||||
.FromClient(gameEvent.Origin)
|
||||
.OfType(nameof(EFInboxMessage))
|
||||
.ExpiresIn(TimeSpan.FromDays(7)));
|
||||
|
||||
try
|
||||
{
|
||||
context.Set<EFInboxMessage>().Add(newMessage);
|
||||
|
@ -24,7 +24,7 @@ namespace IW4MAdmin.Application.Commands
|
||||
Name = "readmessage";
|
||||
Description = _translationLookup["COMMANDS_READ_MESSAGE_DESC"];
|
||||
Alias = "rm";
|
||||
Permission = EFClient.Permission.Flagged;
|
||||
Permission = EFClient.Permission.User;
|
||||
|
||||
_contextFactory = contextFactory;
|
||||
_logger = logger;
|
||||
|
@ -564,6 +564,55 @@
|
||||
"Alias": "Momentum"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"Game": "H1",
|
||||
"Gametypes": [
|
||||
{
|
||||
"Name": "conf",
|
||||
"Alias": "Kill Confirmed"
|
||||
},
|
||||
{
|
||||
"Name": "ctf",
|
||||
"Alias": "Capture The Flag"
|
||||
},
|
||||
{
|
||||
"Name": "dd",
|
||||
"Alias": "Demolition"
|
||||
},
|
||||
{
|
||||
"Name": "dm",
|
||||
"Alias": "Free For All"
|
||||
},
|
||||
{
|
||||
"Name": "dom",
|
||||
"Alias": "Domination"
|
||||
},
|
||||
{
|
||||
"Name": "gun",
|
||||
"Alias": "Gun Game"
|
||||
},
|
||||
{
|
||||
"Name": "hp",
|
||||
"Alias": "Hardpoint"
|
||||
},
|
||||
{
|
||||
"Name": "koth",
|
||||
"Alias": "Headquarters"
|
||||
},
|
||||
{
|
||||
"Name": "sab",
|
||||
"Alias": "Sabotage"
|
||||
},
|
||||
{
|
||||
"Name": "sd",
|
||||
"Alias": "Search & Destroy"
|
||||
},
|
||||
{
|
||||
"Name": "war",
|
||||
"Alias": "Team Deathmatch"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"Maps": [
|
||||
@ -1768,6 +1817,103 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"Game": "H1",
|
||||
"Maps": [
|
||||
{
|
||||
"Alias": "Ambush",
|
||||
"Name": "mp_convoy"
|
||||
},
|
||||
{
|
||||
"Alias": "Backlot",
|
||||
"Name": "mp_backlot"
|
||||
},
|
||||
{
|
||||
"Alias": "Bloc",
|
||||
"Name": "mp_bloc"
|
||||
},
|
||||
{
|
||||
"Alias": "Bog",
|
||||
"Name": "mp_bog"
|
||||
},
|
||||
{
|
||||
"Alias": "Countdown",
|
||||
"Name": "mp_countdown"
|
||||
},
|
||||
{
|
||||
"Alias": "Crash",
|
||||
"Name": "mp_crash"
|
||||
},
|
||||
{
|
||||
"Alias": "Crossfire",
|
||||
"Name": "mp_crossfire"
|
||||
},
|
||||
{
|
||||
"Alias": "District",
|
||||
"Name": "mp_citystreets"
|
||||
},
|
||||
{
|
||||
"Alias": "Downpour",
|
||||
"Name": "mp_farm"
|
||||
},
|
||||
{
|
||||
"Alias": "Overgrown",
|
||||
"Name": "mp_overgrown"
|
||||
},
|
||||
{
|
||||
"Alias": "Pipeline",
|
||||
"Name": "mp_pipeline"
|
||||
},
|
||||
{
|
||||
"Alias": "Shipment",
|
||||
"Name": "mp_shipment"
|
||||
},
|
||||
{
|
||||
"Alias": "Showdown",
|
||||
"Name": "mp_showdown"
|
||||
},
|
||||
{
|
||||
"Alias": "Strike",
|
||||
"Name": "mp_strike"
|
||||
},
|
||||
{
|
||||
"Alias": "Vacant",
|
||||
"Name": "mp_vacant"
|
||||
},
|
||||
{
|
||||
"Alias": "Wet Work",
|
||||
"Name": "mp_cargoship"
|
||||
},
|
||||
{
|
||||
"Alias": "Winter Crash",
|
||||
"Name": "mp_crash_snow"
|
||||
},
|
||||
{
|
||||
"Alias": "Broadcast",
|
||||
"Name": "mp_broadcast"
|
||||
},
|
||||
{
|
||||
"Alias": "Creek",
|
||||
"Name": "mp_creek"
|
||||
},
|
||||
{
|
||||
"Alias": "Chinatown",
|
||||
"Name": "mp_carentan"
|
||||
},
|
||||
{
|
||||
"Alias": "Killhouse",
|
||||
"Name": "mp_killhouse"
|
||||
},
|
||||
{
|
||||
"Alias": "Day Break",
|
||||
"Name": "mp_farm_spring"
|
||||
},
|
||||
{
|
||||
"Alias": "Beach Bog",
|
||||
"Name": "mp_bog_summer"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"Game": "CSGO",
|
||||
"Maps": [
|
||||
|
@ -97,18 +97,21 @@ namespace IW4MAdmin.Application.EventParsers
|
||||
{Configuration.Say, GameEvent.EventType.Say},
|
||||
{Configuration.Kill, GameEvent.EventType.Kill},
|
||||
{Configuration.MapChange, GameEvent.EventType.MapChange},
|
||||
{Configuration.MapEnd, GameEvent.EventType.MapEnd}
|
||||
{Configuration.MapEnd, GameEvent.EventType.MapEnd},
|
||||
{Configuration.JoinTeam, GameEvent.EventType.JoinTeam}
|
||||
};
|
||||
|
||||
_eventTypeMap = new Dictionary<string, GameEvent.EventType>
|
||||
{
|
||||
{"say", GameEvent.EventType.Say},
|
||||
{"sayteam", GameEvent.EventType.Say},
|
||||
{"chat", GameEvent.EventType.Say},
|
||||
{"chatteam", GameEvent.EventType.Say},
|
||||
{"K", GameEvent.EventType.Kill},
|
||||
{"D", GameEvent.EventType.Damage},
|
||||
{"J", GameEvent.EventType.PreConnect},
|
||||
{"JT", GameEvent.EventType.JoinTeam},
|
||||
{"Q", GameEvent.EventType.PreDisconnect},
|
||||
{"Q", GameEvent.EventType.PreDisconnect}
|
||||
};
|
||||
}
|
||||
|
||||
@ -340,6 +343,11 @@ namespace IW4MAdmin.Application.EventParsers
|
||||
var originName = match.Values[Configuration.JoinTeam.GroupMapping[ParserRegex.GroupType.OriginName]];
|
||||
var team = match.Values[Configuration.JoinTeam.GroupMapping[ParserRegex.GroupType.OriginTeam]];
|
||||
|
||||
if (Configuration.TeamMapping.ContainsKey(team))
|
||||
{
|
||||
team = Configuration.TeamMapping[team].ToString();
|
||||
}
|
||||
|
||||
var networkId = originIdString.IsBotGuid() ?
|
||||
originName.GenerateGuidFromString() :
|
||||
originIdString.ConvertGuidToLong(Configuration.GuidNumberStyle);
|
||||
@ -359,7 +367,7 @@ namespace IW4MAdmin.Application.EventParsers
|
||||
State = EFClient.ClientState.Connected,
|
||||
},
|
||||
Extra = team,
|
||||
RequiredEntity = GameEvent.EventRequiredEntity.None,
|
||||
RequiredEntity = GameEvent.EventRequiredEntity.Origin,
|
||||
GameTime = gameTime,
|
||||
Source = GameEvent.EventSource.Log
|
||||
};
|
||||
|
@ -1,6 +1,8 @@
|
||||
using SharedLibraryCore.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
using SharedLibraryCore.Interfaces;
|
||||
using System.Globalization;
|
||||
using SharedLibraryCore;
|
||||
using SharedLibraryCore.Database.Models;
|
||||
|
||||
namespace IW4MAdmin.Application.EventParsers
|
||||
{
|
||||
@ -23,6 +25,8 @@ namespace IW4MAdmin.Application.EventParsers
|
||||
public ParserRegex MapEnd { get; set; }
|
||||
public NumberStyles GuidNumberStyle { get; set; } = NumberStyles.HexNumber;
|
||||
|
||||
public Dictionary<string, EFClient.TeamType> TeamMapping { get; set; } = new();
|
||||
|
||||
public DynamicEventParserConfiguration(IParserRegexFactory parserRegexFactory)
|
||||
{
|
||||
Say = parserRegexFactory.CreateParserRegex();
|
||||
|
@ -9,6 +9,7 @@ using SharedLibraryCore.Helpers;
|
||||
using SharedLibraryCore.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
@ -24,8 +25,10 @@ using Serilog.Context;
|
||||
using static SharedLibraryCore.Database.Models.EFClient;
|
||||
using Data.Models;
|
||||
using Data.Models.Server;
|
||||
using IW4MAdmin.Application.Alerts;
|
||||
using IW4MAdmin.Application.Commands;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SharedLibraryCore.Alerts;
|
||||
using static Data.Models.Client.EFClient;
|
||||
|
||||
namespace IW4MAdmin
|
||||
@ -73,7 +76,7 @@ namespace IW4MAdmin
|
||||
{
|
||||
ServerLogger.LogDebug("Client slot #{clientNumber} now reserved", clientFromLog.ClientNumber);
|
||||
|
||||
EFClient client = await Manager.GetClientService().GetUnique(clientFromLog.NetworkId);
|
||||
var client = await Manager.GetClientService().GetUnique(clientFromLog.NetworkId, GameName);
|
||||
|
||||
// first time client is connecting to server
|
||||
if (client == null)
|
||||
@ -96,6 +99,8 @@ namespace IW4MAdmin
|
||||
client.ClientNumber = clientFromLog.ClientNumber;
|
||||
client.Score = clientFromLog.Score;
|
||||
client.Ping = clientFromLog.Ping;
|
||||
client.Team = clientFromLog.Team;
|
||||
client.TeamName = clientFromLog.TeamName;
|
||||
client.CurrentServer = this;
|
||||
client.State = ClientState.Connecting;
|
||||
|
||||
@ -114,7 +119,7 @@ namespace IW4MAdmin
|
||||
|
||||
public override async Task OnClientDisconnected(EFClient client)
|
||||
{
|
||||
if (!GetClientsAsList().Any(_client => _client.NetworkId == client.NetworkId))
|
||||
if (GetClientsAsList().All(eachClient => eachClient.NetworkId != client.NetworkId))
|
||||
{
|
||||
using (LogContext.PushProperty("Server", ToString()))
|
||||
{
|
||||
@ -150,11 +155,9 @@ namespace IW4MAdmin
|
||||
{
|
||||
if (E.IsBlocking)
|
||||
{
|
||||
await E.Origin?.Lock();
|
||||
await E.Origin.Lock();
|
||||
}
|
||||
|
||||
bool canExecuteCommand = true;
|
||||
|
||||
try
|
||||
{
|
||||
if (!await ProcessEvent(E))
|
||||
@ -162,53 +165,52 @@ namespace IW4MAdmin
|
||||
return;
|
||||
}
|
||||
|
||||
Command C = null;
|
||||
Command command = null;
|
||||
if (E.Type == GameEvent.EventType.Command)
|
||||
{
|
||||
try
|
||||
{
|
||||
C = await SharedLibraryCore.Commands.CommandProcessing.ValidateCommand(E, Manager.GetApplicationSettings().Configuration(), _commandConfiguration);
|
||||
command = await SharedLibraryCore.Commands.CommandProcessing.ValidateCommand(E, Manager.GetApplicationSettings().Configuration(), _commandConfiguration);
|
||||
}
|
||||
|
||||
catch (CommandException e)
|
||||
{
|
||||
ServerLogger.LogWarning(e, "Error validating command from event {@event}",
|
||||
ServerLogger.LogWarning(e, "Error validating command from event {@Event}",
|
||||
new { E.Type, E.Data, E.Message, E.Subtype, E.IsRemote, E.CorrelationId });
|
||||
E.FailReason = GameEvent.EventFailReason.Invalid;
|
||||
}
|
||||
|
||||
if (C != null)
|
||||
if (command != null)
|
||||
{
|
||||
E.Extra = C;
|
||||
E.Extra = command;
|
||||
}
|
||||
}
|
||||
|
||||
var canExecuteCommand = Manager.CommandInterceptors.All(interceptor =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var loginPlugin = Manager.Plugins.FirstOrDefault(_plugin => _plugin.Name == "Login");
|
||||
|
||||
if (loginPlugin != null)
|
||||
{
|
||||
await loginPlugin.OnEventAsync(E, this);
|
||||
return interceptor(E);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if (!canExecuteCommand)
|
||||
{
|
||||
E.Origin.Tell(_translationLookup["SERVER_COMMANDS_INTERCEPTED"]);
|
||||
}
|
||||
|
||||
catch (AuthorizationException e)
|
||||
else if (E.Type == GameEvent.EventType.Command && E.Extra is Command cmd)
|
||||
{
|
||||
E.Origin.Tell($"{loc["COMMAND_NOTAUTHORIZED"]} - {e.Message}");
|
||||
canExecuteCommand = false;
|
||||
}
|
||||
|
||||
// hack: this prevents commands from getting executing that 'shouldn't' be
|
||||
if (E.Type == GameEvent.EventType.Command && E.Extra is Command command &&
|
||||
(canExecuteCommand || E.Origin?.Level == Permission.Console))
|
||||
{
|
||||
ServerLogger.LogInformation("Executing command {comamnd} for {client}", command.Name, E.Origin.ToString());
|
||||
await command.ExecuteAsync(E);
|
||||
ServerLogger.LogInformation("Executing command {Command} for {Client}", cmd.Name,
|
||||
E.Origin.ToString());
|
||||
await cmd.ExecuteAsync(E);
|
||||
}
|
||||
|
||||
var pluginTasks = Manager.Plugins
|
||||
.Where(_plugin => _plugin.Name != "Login")
|
||||
.Select(async plugin => await CreatePluginTask(plugin, E));
|
||||
|
||||
await Task.WhenAll(pluginTasks);
|
||||
@ -304,6 +306,14 @@ namespace IW4MAdmin
|
||||
if (!Manager.GetApplicationSettings().Configuration().IgnoreServerConnectionLost)
|
||||
{
|
||||
Console.WriteLine(loc["SERVER_ERROR_COMMUNICATION"].FormatExt($"{IP}:{Port}"));
|
||||
|
||||
var alert = Alert.AlertState.Build().OfType(E.Type.ToString())
|
||||
.WithCategory(Alert.AlertCategory.Error)
|
||||
.FromSource("System")
|
||||
.WithMessage(loc["SERVER_ERROR_COMMUNICATION"].FormatExt($"{IP}:{Port}"))
|
||||
.ExpiresIn(TimeSpan.FromDays(1));
|
||||
|
||||
Manager.AlertManager.AddAlert(alert);
|
||||
}
|
||||
|
||||
Throttled = true;
|
||||
@ -316,7 +326,15 @@ namespace IW4MAdmin
|
||||
|
||||
if (!Manager.GetApplicationSettings().Configuration().IgnoreServerConnectionLost)
|
||||
{
|
||||
Console.WriteLine(loc["MANAGER_CONNECTION_REST"].FormatExt($"[{IP}:{Port}]"));
|
||||
Console.WriteLine(loc["MANAGER_CONNECTION_REST"].FormatExt($"{IP}:{Port}"));
|
||||
|
||||
var alert = Alert.AlertState.Build().OfType(E.Type.ToString())
|
||||
.WithCategory(Alert.AlertCategory.Information)
|
||||
.FromSource("System")
|
||||
.WithMessage(loc["MANAGER_CONNECTION_REST"].FormatExt($"{IP}:{Port}"))
|
||||
.ExpiresIn(TimeSpan.FromDays(1));
|
||||
|
||||
Manager.AlertManager.AddAlert(alert);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(CustomSayName))
|
||||
@ -353,9 +371,9 @@ namespace IW4MAdmin
|
||||
var clientTag = await _metaService.GetPersistentMetaByLookup(EFMeta.ClientTagV2,
|
||||
EFMeta.ClientTagNameV2, E.Origin.ClientId, Manager.CancellationToken);
|
||||
|
||||
if (clientTag?.LinkedMeta != null)
|
||||
if (clientTag?.Value != null)
|
||||
{
|
||||
E.Origin.Tag = clientTag.LinkedMeta.Value;
|
||||
E.Origin.Tag = clientTag.Value;
|
||||
}
|
||||
|
||||
try
|
||||
@ -429,6 +447,7 @@ namespace IW4MAdmin
|
||||
Clients[E.Origin.ClientNumber] = E.Origin;
|
||||
try
|
||||
{
|
||||
E.Origin.GameName = (Reference.Game)GameName;
|
||||
E.Origin = await OnClientConnected(E.Origin);
|
||||
E.Target = E.Origin;
|
||||
}
|
||||
@ -496,7 +515,7 @@ namespace IW4MAdmin
|
||||
|
||||
E.Target.SetLevel(Permission.User, E.Origin);
|
||||
await Manager.GetPenaltyService().RemoveActivePenalties(E.Target.AliasLinkId, E.Target.NetworkId,
|
||||
E.Target.CurrentAlias?.IPAddress);
|
||||
E.Target.GameName, E.Target.CurrentAlias?.IPAddress);
|
||||
await Manager.GetPenaltyService().Create(unflagPenalty);
|
||||
}
|
||||
|
||||
@ -506,7 +525,8 @@ namespace IW4MAdmin
|
||||
{
|
||||
Origin = E.Origin,
|
||||
Target = E.Target,
|
||||
Reason = E.Data
|
||||
Reason = E.Data,
|
||||
ReportedOn = DateTime.UtcNow
|
||||
});
|
||||
|
||||
var newReport = new EFPenalty()
|
||||
@ -569,10 +589,8 @@ namespace IW4MAdmin
|
||||
Time = DateTime.UtcNow
|
||||
});
|
||||
|
||||
await _metaService.SetPersistentMeta("LastMapPlayed", CurrentMap.Alias, E.Origin.ClientId,
|
||||
Manager.CancellationToken);
|
||||
await _metaService.SetPersistentMeta("LastServerPlayed", E.Owner.Hostname, E.Origin.ClientId,
|
||||
Manager.CancellationToken);
|
||||
await _metaService.SetPersistentMeta("LastMapPlayed", CurrentMap.Alias, E.Origin.ClientId);
|
||||
await _metaService.SetPersistentMeta("LastServerPlayed", E.Owner.Hostname, E.Origin.ClientId);
|
||||
}
|
||||
|
||||
else if (E.Type == GameEvent.EventType.PreDisconnect)
|
||||
@ -643,7 +661,7 @@ namespace IW4MAdmin
|
||||
}
|
||||
}
|
||||
|
||||
ChatHistory.Add(new ChatInfo()
|
||||
ChatHistory.Add(new ChatInfo
|
||||
{
|
||||
Name = E.Origin.Name,
|
||||
Message = message,
|
||||
@ -668,24 +686,51 @@ namespace IW4MAdmin
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (dict.ContainsKey("gametype"))
|
||||
{
|
||||
Gametype = dict["gametype"];
|
||||
Hostname = dict["hostname"];
|
||||
}
|
||||
|
||||
string mapname = dict["mapname"] ?? CurrentMap.Name;
|
||||
UpdateMap(mapname);
|
||||
if (dict.ContainsKey("hostname"))
|
||||
{
|
||||
Hostname = dict["hostname"];
|
||||
}
|
||||
|
||||
var newMapName = dict.ContainsKey("mapname")
|
||||
? dict["mapname"] ?? CurrentMap.Name
|
||||
: CurrentMap.Name;
|
||||
UpdateMap(newMapName);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
var dict = (Dictionary<string, string>)E.Extra;
|
||||
if (dict.ContainsKey("g_gametype"))
|
||||
{
|
||||
Gametype = dict["g_gametype"];
|
||||
Hostname = dict["sv_hostname"];
|
||||
MaxClients = int.Parse(dict["sv_maxclients"]);
|
||||
}
|
||||
|
||||
string mapname = dict["mapname"];
|
||||
UpdateMap(mapname);
|
||||
if (dict.ContainsKey("sv_hostname"))
|
||||
{
|
||||
Hostname = dict["sv_hostname"];
|
||||
}
|
||||
|
||||
if (dict.ContainsKey("sv_maxclients"))
|
||||
{
|
||||
MaxClients = int.Parse(dict["sv_maxclients"]);
|
||||
}
|
||||
|
||||
else if (dict.ContainsKey("com_maxclients"))
|
||||
{
|
||||
MaxClients = int.Parse(dict["com_maxclients"]);
|
||||
}
|
||||
|
||||
if (dict.ContainsKey("mapname"))
|
||||
{
|
||||
UpdateMap(dict["mapname"]);
|
||||
}
|
||||
}
|
||||
|
||||
if (E.GameTime.HasValue)
|
||||
@ -722,6 +767,34 @@ namespace IW4MAdmin
|
||||
E.Origin.UpdateTeam(E.Extra as string);
|
||||
}
|
||||
|
||||
else if (E.Type == GameEvent.EventType.MetaUpdated)
|
||||
{
|
||||
if (E.Extra is "PersistentClientGuid")
|
||||
{
|
||||
var parts = E.Data.Split(",");
|
||||
|
||||
if (parts.Length == 2 && int.TryParse(parts[0], out var high) &&
|
||||
int.TryParse(parts[1], out var low))
|
||||
{
|
||||
var guid = long.Parse(high.ToString("X") + low.ToString("X"), NumberStyles.HexNumber);
|
||||
|
||||
var penalties = await Manager.GetPenaltyService()
|
||||
.GetActivePenaltiesByIdentifier(null, guid, (Reference.Game)GameName);
|
||||
var banPenalty =
|
||||
penalties.FirstOrDefault(penalty => penalty.Type == EFPenalty.PenaltyType.Ban);
|
||||
|
||||
if (banPenalty is not null && E.Origin.Level != Permission.Banned)
|
||||
{
|
||||
ServerLogger.LogInformation(
|
||||
"Banning {Client} as they have have provided a persistent clientId of {PersistentClientId}, which is banned",
|
||||
E.Origin.ToString(), guid);
|
||||
E.Origin.Ban(loc["SERVER_BAN_EVADE"].FormatExt(guid),
|
||||
Utilities.IW4MAdminClient(this), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lock (ChatHistory)
|
||||
{
|
||||
while (ChatHistory.Count > Math.Ceiling(ClientNum / 2.0))
|
||||
@ -743,7 +816,7 @@ namespace IW4MAdmin
|
||||
|
||||
private async Task OnClientUpdate(EFClient origin)
|
||||
{
|
||||
var client = Manager.GetActiveClients().FirstOrDefault(c => c.NetworkId == origin.NetworkId);
|
||||
var client = GetClientsAsList().FirstOrDefault(c => c.NetworkId == origin.NetworkId);
|
||||
|
||||
if (client == null)
|
||||
{
|
||||
@ -788,10 +861,16 @@ namespace IW4MAdmin
|
||||
/// array index 2 = updated clients
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
async Task<List<EFClient>[]> PollPlayersAsync()
|
||||
async Task<List<EFClient>[]> PollPlayersAsync(CancellationToken token)
|
||||
{
|
||||
var currentClients = GetClientsAsList();
|
||||
var statusResponse = await this.GetStatusAsync(Manager.CancellationToken);
|
||||
var statusResponse = await this.GetStatusAsync(token);
|
||||
|
||||
if (statusResponse is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var polledClients = statusResponse.Clients.AsEnumerable();
|
||||
|
||||
if (Manager.GetApplicationSettings().Configuration().IgnoreBots)
|
||||
@ -903,22 +982,16 @@ namespace IW4MAdmin
|
||||
|
||||
await e.WaitAsync(Utilities.DefaultCommandTimeout, new CancellationTokenRegistration().Token);
|
||||
}
|
||||
|
||||
foreach (var plugin in Manager.Plugins)
|
||||
{
|
||||
await plugin.OnUnloadAsync();
|
||||
}
|
||||
}
|
||||
|
||||
DateTime start = DateTime.Now;
|
||||
DateTime playerCountStart = DateTime.Now;
|
||||
DateTime lastCount = DateTime.Now;
|
||||
private DateTime _lastMessageSent = DateTime.Now;
|
||||
private DateTime _lastPlayerCount = DateTime.Now;
|
||||
|
||||
public override async Task<bool> ProcessUpdatesAsync(CancellationToken cts)
|
||||
public override async Task<bool> ProcessUpdatesAsync(CancellationToken token)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (cts.IsCancellationRequested)
|
||||
if (token.IsCancellationRequested)
|
||||
{
|
||||
await ShutdownInternal();
|
||||
return true;
|
||||
@ -926,17 +999,24 @@ namespace IW4MAdmin
|
||||
|
||||
try
|
||||
{
|
||||
if (Manager.GetApplicationSettings().Configuration().RConPollRate == int.MaxValue && Utilities.IsDevelopment)
|
||||
if (Manager.GetApplicationSettings().Configuration().RConPollRate == int.MaxValue &&
|
||||
Utilities.IsDevelopment)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var polledClients = await PollPlayersAsync();
|
||||
var polledClients = await PollPlayersAsync(token);
|
||||
|
||||
foreach (var disconnectingClient in polledClients[1].Where(_client => !_client.IsZombieClient /* ignores "fake" zombie clients */))
|
||||
if (polledClients is null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach (var disconnectingClient in polledClients[1]
|
||||
.Where(client => !client.IsZombieClient /* ignores "fake" zombie clients */))
|
||||
{
|
||||
disconnectingClient.CurrentServer = this;
|
||||
var e = new GameEvent()
|
||||
var e = new GameEvent
|
||||
{
|
||||
Type = GameEvent.EventType.PreDisconnect,
|
||||
Origin = disconnectingClient,
|
||||
@ -949,23 +1029,20 @@ namespace IW4MAdmin
|
||||
}
|
||||
|
||||
// this are our new connecting clients
|
||||
foreach (var client in polledClients[0])
|
||||
foreach (var client in polledClients[0].Where(client =>
|
||||
!string.IsNullOrEmpty(client.Name) && (client.Ping != 999 || client.IsBot)))
|
||||
{
|
||||
// note: this prevents players in ZMBI state from being registered with no name
|
||||
if (string.IsNullOrEmpty(client.Name) || (client.Ping == 999 && !client.IsBot))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
client.CurrentServer = this;
|
||||
var e = new GameEvent()
|
||||
client.GameName = (Reference.Game)GameName;
|
||||
|
||||
var e = new GameEvent
|
||||
{
|
||||
Type = GameEvent.EventType.PreConnect,
|
||||
Origin = client,
|
||||
Owner = this,
|
||||
IsBlocking = true,
|
||||
Extra = client.GetAdditionalProperty<string>("BotGuid"),
|
||||
Source = GameEvent.EventSource.Status
|
||||
Source = GameEvent.EventSource.Status,
|
||||
};
|
||||
|
||||
Manager.AddEvent(e);
|
||||
@ -976,19 +1053,19 @@ namespace IW4MAdmin
|
||||
foreach (var client in polledClients[2])
|
||||
{
|
||||
client.CurrentServer = this;
|
||||
var e = new GameEvent()
|
||||
var gameEvent = new GameEvent
|
||||
{
|
||||
Type = GameEvent.EventType.Update,
|
||||
Origin = client,
|
||||
Owner = this
|
||||
};
|
||||
|
||||
Manager.AddEvent(e);
|
||||
Manager.AddEvent(gameEvent);
|
||||
}
|
||||
|
||||
if (Throttled)
|
||||
{
|
||||
var _event = new GameEvent()
|
||||
var gameEvent = new GameEvent
|
||||
{
|
||||
Type = GameEvent.EventType.ConnectionRestored,
|
||||
Owner = this,
|
||||
@ -996,65 +1073,52 @@ namespace IW4MAdmin
|
||||
Target = Utilities.IW4MAdminClient(this)
|
||||
};
|
||||
|
||||
Manager.AddEvent(_event);
|
||||
Manager.AddEvent(gameEvent);
|
||||
}
|
||||
|
||||
LastPoll = DateTime.Now;
|
||||
}
|
||||
|
||||
catch (NetworkException e)
|
||||
catch (NetworkException ex)
|
||||
{
|
||||
if (!Throttled)
|
||||
if (Throttled)
|
||||
{
|
||||
var _event = new GameEvent()
|
||||
return true;
|
||||
}
|
||||
|
||||
var gameEvent = new GameEvent
|
||||
{
|
||||
Type = GameEvent.EventType.ConnectionLost,
|
||||
Owner = this,
|
||||
Origin = Utilities.IW4MAdminClient(this),
|
||||
Target = Utilities.IW4MAdminClient(this),
|
||||
Extra = e,
|
||||
Extra = ex,
|
||||
Data = ConnectionErrors.ToString()
|
||||
};
|
||||
|
||||
Manager.AddEvent(_event);
|
||||
Manager.AddEvent(gameEvent);
|
||||
return true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
RunServerCollection();
|
||||
}
|
||||
|
||||
if (DateTime.Now - _lastMessageSent <=
|
||||
TimeSpan.FromSeconds(Manager.GetApplicationSettings().Configuration().AutoMessagePeriod) ||
|
||||
BroadcastMessages.Count <= 0 || ClientNum <= 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
LastMessage = DateTime.Now - start;
|
||||
lastCount = DateTime.Now;
|
||||
|
||||
var appConfig = _serviceProvider.GetService<ApplicationConfiguration>();
|
||||
// update the player history
|
||||
if (lastCount - playerCountStart >= appConfig.ServerDataCollectionInterval)
|
||||
{
|
||||
var maxItems = Math.Ceiling(appConfig.MaxClientHistoryTime.TotalMinutes /
|
||||
appConfig.ServerDataCollectionInterval.TotalMinutes);
|
||||
while ( ClientHistory.Count > maxItems)
|
||||
{
|
||||
ClientHistory.Dequeue();
|
||||
}
|
||||
|
||||
ClientHistory.Enqueue(new PlayerHistory(ClientNum));
|
||||
playerCountStart = DateTime.Now;
|
||||
}
|
||||
|
||||
// send out broadcast messages
|
||||
if (LastMessage.TotalSeconds > Manager.GetApplicationSettings().Configuration().AutoMessagePeriod
|
||||
&& BroadcastMessages.Count > 0
|
||||
&& ClientNum > 0)
|
||||
{
|
||||
string[] messages = (await this.ProcessMessageToken(Manager.GetMessageTokens(), BroadcastMessages[NextMessage])).Split(Environment.NewLine);
|
||||
var messages =
|
||||
(await this.ProcessMessageToken(Manager.GetMessageTokens(), BroadcastMessages[NextMessage])).Split(
|
||||
Environment.NewLine);
|
||||
await BroadcastAsync(messages, token: Manager.CancellationToken);
|
||||
|
||||
foreach (string message in messages)
|
||||
{
|
||||
Broadcast(message);
|
||||
}
|
||||
|
||||
NextMessage = NextMessage == (BroadcastMessages.Count - 1) ? 0 : NextMessage + 1;
|
||||
start = DateTime.Now;
|
||||
}
|
||||
NextMessage = NextMessage == BroadcastMessages.Count - 1 ? 0 : NextMessage + 1;
|
||||
_lastMessageSent = DateTime.Now;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1072,6 +1136,7 @@ namespace IW4MAdmin
|
||||
{
|
||||
ServerLogger.LogWarning(e, "Undesirable exception occured during processing updates");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1081,11 +1146,40 @@ namespace IW4MAdmin
|
||||
{
|
||||
ServerLogger.LogError(e, "Unexpected exception occured during processing updates");
|
||||
}
|
||||
|
||||
Console.WriteLine(loc["SERVER_ERROR_EXCEPTION"].FormatExt($"[{IP}:{Port}]"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void RunServerCollection()
|
||||
{
|
||||
var appConfig = _serviceProvider.GetService<ApplicationConfiguration>();
|
||||
|
||||
if (DateTime.Now - _lastPlayerCount < appConfig?.ServerDataCollectionInterval)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var maxItems = Math.Ceiling(appConfig.MaxClientHistoryTime.TotalMinutes /
|
||||
appConfig.ServerDataCollectionInterval.TotalMinutes);
|
||||
|
||||
while (ClientHistory.ClientCounts.Count > maxItems)
|
||||
{
|
||||
ClientHistory.ClientCounts.RemoveAt(0);
|
||||
}
|
||||
|
||||
ClientHistory.ClientCounts.Add(new ClientCountSnapshot
|
||||
{
|
||||
ClientCount = ClientNum,
|
||||
ConnectionInterrupted = Throttled,
|
||||
Time = DateTime.UtcNow,
|
||||
Map = CurrentMap.Name
|
||||
});
|
||||
|
||||
_lastPlayerCount = DateTime.Now;
|
||||
}
|
||||
|
||||
public async Task Initialize()
|
||||
{
|
||||
try
|
||||
@ -1204,28 +1298,17 @@ namespace IW4MAdmin
|
||||
this.GamePassword = gamePassword.Value;
|
||||
UpdateMap(mapname);
|
||||
|
||||
if (RconParser.CanGenerateLogPath)
|
||||
if (RconParser.CanGenerateLogPath && string.IsNullOrEmpty(ServerConfig.ManualLogPath))
|
||||
{
|
||||
bool needsRestart = false;
|
||||
|
||||
if (logsync.Value == 0)
|
||||
{
|
||||
await this.SetDvarAsync("g_logsync", 2, Manager.CancellationToken); // set to 2 for continous in other games, clamps to 1 for IW4
|
||||
needsRestart = true;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(logfile.Value))
|
||||
{
|
||||
logfile.Value = "games_mp.log";
|
||||
await this.SetDvarAsync("g_log", logfile.Value, Manager.CancellationToken);
|
||||
needsRestart = true;
|
||||
}
|
||||
|
||||
if (needsRestart)
|
||||
{
|
||||
// disabling this for the time being
|
||||
/*Logger.WriteWarning("Game log file not properly initialized, restarting map...");
|
||||
await this.ExecuteCommandAsync("map_restart");*/
|
||||
}
|
||||
|
||||
// this DVAR isn't set until the a map is loaded
|
||||
@ -1432,6 +1515,11 @@ namespace IW4MAdmin
|
||||
ServerLogger.LogDebug("Creating tempban penalty for {TargetClient}", targetClient.ToString());
|
||||
await newPenalty.TryCreatePenalty(Manager.GetPenaltyService(), ServerLogger);
|
||||
|
||||
foreach (var reports in Manager.GetServers().Select(server => server.Reports))
|
||||
{
|
||||
reports.RemoveAll(report => report.Target.ClientId == targetClient.ClientId);
|
||||
}
|
||||
|
||||
if (activeClient.IsIngame)
|
||||
{
|
||||
var formattedKick = string.Format(RconParser.Configuration.CommandPrefixes.Kick,
|
||||
@ -1461,6 +1549,11 @@ namespace IW4MAdmin
|
||||
activeClient.SetLevel(Permission.Banned, originClient);
|
||||
await newPenalty.TryCreatePenalty(Manager.GetPenaltyService(), ServerLogger);
|
||||
|
||||
foreach (var reports in Manager.GetServers().Select(server => server.Reports))
|
||||
{
|
||||
reports.RemoveAll(report => report.Target.ClientId == targetClient.ClientId);
|
||||
}
|
||||
|
||||
if (activeClient.IsIngame)
|
||||
{
|
||||
ServerLogger.LogDebug("Attempting to kicking newly banned client {ActiveClient}", activeClient.ToString());
|
||||
@ -1489,7 +1582,7 @@ namespace IW4MAdmin
|
||||
ServerLogger.LogDebug("Creating unban penalty for {targetClient}", targetClient.ToString());
|
||||
targetClient.SetLevel(Permission.User, originClient);
|
||||
await Manager.GetPenaltyService().RemoveActivePenalties(targetClient.AliasLink.AliasLinkId,
|
||||
targetClient.NetworkId, targetClient.CurrentAlias?.IPAddress);
|
||||
targetClient.NetworkId, targetClient.GameName, targetClient.CurrentAlias?.IPAddress);
|
||||
await Manager.GetPenaltyService().Create(unbanPenalty);
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ using System.Threading.Tasks;
|
||||
using Data.Abstractions;
|
||||
using Data.Helpers;
|
||||
using Integrations.Source.Extensions;
|
||||
using IW4MAdmin.Application.Alerts;
|
||||
using IW4MAdmin.Application.Extensions;
|
||||
using IW4MAdmin.Application.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@ -77,8 +78,12 @@ namespace IW4MAdmin.Application
|
||||
/// <param name="e"></param>
|
||||
private static async void OnCancelKey(object sender, ConsoleCancelEventArgs e)
|
||||
{
|
||||
_serverManager?.Stop();
|
||||
if (_applicationTask != null)
|
||||
if (_serverManager is not null)
|
||||
{
|
||||
await _serverManager.Stop();
|
||||
}
|
||||
|
||||
if (_applicationTask is not null)
|
||||
{
|
||||
await _applicationTask;
|
||||
}
|
||||
@ -154,7 +159,10 @@ namespace IW4MAdmin.Application
|
||||
Console.WriteLine(e.Message);
|
||||
}
|
||||
|
||||
_serverManager?.Stop();
|
||||
if (_serverManager is not null)
|
||||
{
|
||||
await _serverManager?.Stop();
|
||||
}
|
||||
|
||||
Console.WriteLine(exitMessage);
|
||||
await Console.In.ReadAsync(new char[1], 0, 1);
|
||||
@ -405,7 +413,9 @@ namespace IW4MAdmin.Application
|
||||
.AddSingleton<IScriptCommandFactory, ScriptCommandFactory>()
|
||||
.AddSingleton<IAuditInformationRepository, AuditInformationRepository>()
|
||||
.AddSingleton<IEntityService<EFClient>, ClientService>()
|
||||
#pragma warning disable CS0618
|
||||
.AddSingleton<IMetaService, MetaService>()
|
||||
#pragma warning restore CS0618
|
||||
.AddSingleton<IMetaServiceV2, MetaServiceV2>()
|
||||
.AddSingleton<ClientService>()
|
||||
.AddSingleton<PenaltyService>()
|
||||
@ -438,7 +448,10 @@ namespace IW4MAdmin.Application
|
||||
.AddSingleton<IServerDataViewer, ServerDataViewer>()
|
||||
.AddSingleton<IServerDataCollector, ServerDataCollector>()
|
||||
.AddSingleton<IEventPublisher, EventPublisher>()
|
||||
.AddSingleton<IGeoLocationService>(new GeoLocationService(Path.Join(".", "Resources", "GeoLite2-Country.mmdb")))
|
||||
.AddSingleton<IAlertManager, AlertManager>()
|
||||
.AddTransient<IScriptPluginTimerHelper, ScriptPluginTimerHelper>()
|
||||
.AddSingleton<IInteractionRegistration, InteractionRegistration>()
|
||||
.AddSingleton(translationLookup)
|
||||
.AddDatabaseContextOptions(appConfig);
|
||||
|
||||
|
@ -83,7 +83,6 @@ namespace IW4MAdmin.Application.Meta
|
||||
Value = lastMapMeta.Value,
|
||||
ShouldDisplay = true,
|
||||
Type = MetaType.Information,
|
||||
Column = 1,
|
||||
Order = 6
|
||||
});
|
||||
}
|
||||
@ -101,8 +100,7 @@ namespace IW4MAdmin.Application.Meta
|
||||
Value = lastServerMeta.Value,
|
||||
ShouldDisplay = true,
|
||||
Type = MetaType.Information,
|
||||
Column = 0,
|
||||
Order = 6
|
||||
Order = 7
|
||||
});
|
||||
}
|
||||
|
||||
@ -120,8 +118,7 @@ namespace IW4MAdmin.Application.Meta
|
||||
Key = _transLookup["WEBFRONT_PROFILE_META_PLAY_TIME"],
|
||||
Value = TimeSpan.FromHours(client.TotalConnectionTime / 3600.0).HumanizeForCurrentCulture(),
|
||||
ShouldDisplay = true,
|
||||
Column = 1,
|
||||
Order = 0,
|
||||
Order = 8,
|
||||
Type = MetaType.Information
|
||||
});
|
||||
|
||||
@ -131,8 +128,7 @@ namespace IW4MAdmin.Application.Meta
|
||||
Key = _transLookup["WEBFRONT_PROFILE_META_FIRST_SEEN"],
|
||||
Value = (DateTime.UtcNow - client.FirstConnection).HumanizeForCurrentCulture(),
|
||||
ShouldDisplay = true,
|
||||
Column = 1,
|
||||
Order = 1,
|
||||
Order = 9,
|
||||
Type = MetaType.Information
|
||||
});
|
||||
|
||||
@ -142,8 +138,7 @@ namespace IW4MAdmin.Application.Meta
|
||||
Key = _transLookup["WEBFRONT_PROFILE_META_LAST_SEEN"],
|
||||
Value = (DateTime.UtcNow - client.LastConnection).HumanizeForCurrentCulture(),
|
||||
ShouldDisplay = true,
|
||||
Column = 1,
|
||||
Order = 2,
|
||||
Order = 10,
|
||||
Type = MetaType.Information
|
||||
});
|
||||
|
||||
@ -154,8 +149,7 @@ namespace IW4MAdmin.Application.Meta
|
||||
Value = client.Connections.ToString("#,##0",
|
||||
new System.Globalization.CultureInfo(Utilities.CurrentLocalization.LocalizationName)),
|
||||
ShouldDisplay = true,
|
||||
Column = 1,
|
||||
Order = 3,
|
||||
Order = 11,
|
||||
Type = MetaType.Information
|
||||
});
|
||||
|
||||
@ -167,8 +161,7 @@ namespace IW4MAdmin.Application.Meta
|
||||
? Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_CLIENT_META_TRUE"]
|
||||
: Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_CLIENT_META_FALSE"],
|
||||
IsSensitive = true,
|
||||
Column = 1,
|
||||
Order = 4,
|
||||
Order = 12,
|
||||
Type = MetaType.Information
|
||||
});
|
||||
|
||||
|
@ -11,6 +11,7 @@ using SharedLibraryCore.Dtos.Meta.Responses;
|
||||
using SharedLibraryCore.Helpers;
|
||||
using SharedLibraryCore.Interfaces;
|
||||
using SharedLibraryCore.QueryHelper;
|
||||
using SharedLibraryCore.Services;
|
||||
using ILogger = Microsoft.Extensions.Logging.ILogger;
|
||||
|
||||
namespace IW4MAdmin.Application.Meta
|
||||
@ -19,7 +20,8 @@ namespace IW4MAdmin.Application.Meta
|
||||
/// implementation of IResourceQueryHelper
|
||||
/// used to pull in penalties applied to a given client id
|
||||
/// </summary>
|
||||
public class ReceivedPenaltyResourceQueryHelper : IResourceQueryHelper<ClientPaginationRequest, ReceivedPenaltyResponse>
|
||||
public class
|
||||
ReceivedPenaltyResourceQueryHelper : IResourceQueryHelper<ClientPaginationRequest, ReceivedPenaltyResponse>
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IDatabaseContextFactory _contextFactory;
|
||||
@ -33,7 +35,8 @@ namespace IW4MAdmin.Application.Meta
|
||||
_appConfig = appConfig;
|
||||
}
|
||||
|
||||
public async Task<ResourceQueryHelperResult<ReceivedPenaltyResponse>> QueryResource(ClientPaginationRequest query)
|
||||
public async Task<ResourceQueryHelperResult<ReceivedPenaltyResponse>> QueryResource(
|
||||
ClientPaginationRequest query)
|
||||
{
|
||||
var linkedPenaltyType = Utilities.LinkedPenaltyTypes();
|
||||
await using var ctx = _contextFactory.CreateContext(enableTracking: false);
|
||||
@ -48,13 +51,20 @@ namespace IW4MAdmin.Application.Meta
|
||||
linkedPenaltyType.Contains(_penalty.Type) && _penalty.LinkId == linkId.AliasLinkId);
|
||||
|
||||
IQueryable<EFPenalty> iqIpLinkedPenalties = null;
|
||||
IQueryable<EFPenalty> identifierPenalties = null;
|
||||
|
||||
if (!_appConfig.EnableImplicitAccountLinking)
|
||||
{
|
||||
var usedIps = await ctx.Aliases.AsNoTracking()
|
||||
.Where(alias => (alias.LinkId == linkId.AliasLinkId || alias.AliasId == linkId.CurrentAliasId) && alias.IPAddress != null)
|
||||
.Where(alias =>
|
||||
(alias.LinkId == linkId.AliasLinkId || alias.AliasId == linkId.CurrentAliasId) &&
|
||||
alias.IPAddress != null)
|
||||
.Select(alias => alias.IPAddress).ToListAsync();
|
||||
|
||||
identifierPenalties = ctx.PenaltyIdentifiers.AsNoTracking().Where(identifier =>
|
||||
identifier.IPv4Address != null && usedIps.Contains(identifier.IPv4Address))
|
||||
.Select(id => id.Penalty);
|
||||
|
||||
var aliasedIds = await ctx.Aliases.AsNoTracking().Where(alias => usedIps.Contains(alias.IPAddress))
|
||||
.Select(alias => alias.LinkId)
|
||||
.ToListAsync();
|
||||
@ -71,6 +81,11 @@ namespace IW4MAdmin.Application.Meta
|
||||
iqAllPenalties = iqPenalties.Union(iqIpLinkedPenalties);
|
||||
}
|
||||
|
||||
if (identifierPenalties != null)
|
||||
{
|
||||
iqAllPenalties = iqPenalties.Union(identifierPenalties);
|
||||
}
|
||||
|
||||
var penalties = await iqAllPenalties
|
||||
.Where(_penalty => _penalty.When < query.Before)
|
||||
.OrderByDescending(_penalty => _penalty.When)
|
||||
@ -97,7 +112,7 @@ namespace IW4MAdmin.Application.Meta
|
||||
{
|
||||
// todo: maybe actually count
|
||||
RetrievedResultCount = penalties.Count,
|
||||
Results = penalties
|
||||
Results = penalties.Distinct()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
12
Application/Misc/AsyncResult.cs
Normal file
12
Application/Misc/AsyncResult.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace IW4MAdmin.Application.Misc;
|
||||
|
||||
public class AsyncResult : IAsyncResult
|
||||
{
|
||||
public object AsyncState { get; set; }
|
||||
public WaitHandle AsyncWaitHandle { get; set; }
|
||||
public bool CompletedSynchronously { get; set; }
|
||||
public bool IsCompleted { get; set; }
|
||||
}
|
@ -33,7 +33,7 @@ namespace IW4MAdmin.Application.Misc
|
||||
builder.Append(header);
|
||||
builder.Append(config.NoticeLineSeparator);
|
||||
// build the reason
|
||||
var reason = _transLookup["GAME_MESSAGE_PENALTY_REASON"].FormatExt(penalty.Offense);
|
||||
var reason = _transLookup["GAME_MESSAGE_PENALTY_REASON"].FormatExt(penalty.Offense.FormatMessageForEngine(config));
|
||||
|
||||
if (isNewLineSeparator)
|
||||
{
|
||||
|
@ -10,6 +10,7 @@ namespace IW4MAdmin.Application.Misc
|
||||
{
|
||||
public event EventHandler<GameEvent> OnClientDisconnect;
|
||||
public event EventHandler<GameEvent> OnClientConnect;
|
||||
public event EventHandler<GameEvent> OnClientMetaUpdated;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
|
||||
@ -29,10 +30,15 @@ namespace IW4MAdmin.Application.Misc
|
||||
OnClientConnect?.Invoke(this, gameEvent);
|
||||
}
|
||||
|
||||
if (gameEvent.Type == GameEvent.EventType.Disconnect)
|
||||
if (gameEvent.Type == GameEvent.EventType.Disconnect && gameEvent.Origin.ClientId != 0)
|
||||
{
|
||||
OnClientDisconnect?.Invoke(this, gameEvent);
|
||||
}
|
||||
|
||||
if (gameEvent.Type == GameEvent.EventType.MetaUpdated)
|
||||
{
|
||||
OnClientMetaUpdated?.Invoke(this, gameEvent);
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
|
13
Application/Misc/GeoLocationResult.cs
Normal file
13
Application/Misc/GeoLocationResult.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using SharedLibraryCore.Interfaces;
|
||||
|
||||
namespace IW4MAdmin.Application.Misc;
|
||||
|
||||
public class GeoLocationResult : IGeoLocationResult
|
||||
{
|
||||
public string Country { get; set; }
|
||||
public string CountryCode { get; set; }
|
||||
public string Region { get; set; }
|
||||
public string ASN { get; set; }
|
||||
public string Timezone { get; set; }
|
||||
public string Organization { get; set; }
|
||||
}
|
40
Application/Misc/GeoLocationService.cs
Normal file
40
Application/Misc/GeoLocationService.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using MaxMind.GeoIP2;
|
||||
using MaxMind.GeoIP2.Responses;
|
||||
using SharedLibraryCore.Interfaces;
|
||||
|
||||
namespace IW4MAdmin.Application.Misc;
|
||||
|
||||
public class GeoLocationService : IGeoLocationService
|
||||
{
|
||||
private readonly string _sourceAddress;
|
||||
|
||||
public GeoLocationService(string sourceAddress)
|
||||
{
|
||||
_sourceAddress = sourceAddress;
|
||||
}
|
||||
|
||||
public Task<IGeoLocationResult> Locate(string address)
|
||||
{
|
||||
CountryResponse country = null;
|
||||
|
||||
try
|
||||
{
|
||||
using var reader = new DatabaseReader(_sourceAddress);
|
||||
reader.TryCountry(address, out country);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
var response = new GeoLocationResult
|
||||
{
|
||||
Country = country?.Country.Name ?? "Unknown",
|
||||
CountryCode = country?.Country.IsoCode ?? ""
|
||||
};
|
||||
|
||||
return Task.FromResult((IGeoLocationResult)response);
|
||||
}
|
||||
}
|
132
Application/Misc/InteractionRegistration.cs
Normal file
132
Application/Misc/InteractionRegistration.cs
Normal file
@ -0,0 +1,132 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Data.Models;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SharedLibraryCore.Interfaces;
|
||||
using InteractionRegistrationCallback =
|
||||
System.Func<int?, Data.Models.Reference.Game?, System.Threading.CancellationToken,
|
||||
System.Threading.Tasks.Task<SharedLibraryCore.Interfaces.IInteractionData>>;
|
||||
|
||||
namespace IW4MAdmin.Application.Misc;
|
||||
|
||||
public class InteractionRegistration : IInteractionRegistration
|
||||
{
|
||||
private readonly ILogger<InteractionRegistration> _logger;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly ConcurrentDictionary<string, InteractionRegistrationCallback> _interactions = new();
|
||||
|
||||
public InteractionRegistration(ILogger<InteractionRegistration> logger, IServiceProvider serviceProvider)
|
||||
{
|
||||
_logger = logger;
|
||||
_serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
public void RegisterScriptInteraction(string interactionName, string source, Delegate interactionRegistration)
|
||||
{
|
||||
var plugin = _serviceProvider.GetRequiredService<IEnumerable<IPlugin>>()
|
||||
.FirstOrDefault(plugin => plugin.Name == source);
|
||||
|
||||
if (plugin is not ScriptPlugin scriptPlugin)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var wrappedDelegate = (int? clientId, Reference.Game? game, CancellationToken token) =>
|
||||
Task.FromResult(
|
||||
scriptPlugin.WrapDelegate<IInteractionData>(interactionRegistration, clientId, game, token));
|
||||
|
||||
if (!_interactions.ContainsKey(interactionName))
|
||||
{
|
||||
_interactions.TryAdd(interactionName, wrappedDelegate);
|
||||
}
|
||||
else
|
||||
{
|
||||
_interactions[interactionName] = wrappedDelegate;
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterInteraction(string interactionName, InteractionRegistrationCallback interactionRegistration)
|
||||
{
|
||||
if (!_interactions.ContainsKey(interactionName))
|
||||
{
|
||||
_interactions.TryAdd(interactionName, interactionRegistration);
|
||||
}
|
||||
else
|
||||
{
|
||||
_interactions[interactionName] = interactionRegistration;
|
||||
}
|
||||
}
|
||||
|
||||
public void UnregisterInteraction(string interactionName)
|
||||
{
|
||||
if (_interactions.ContainsKey(interactionName))
|
||||
{
|
||||
_interactions.TryRemove(interactionName, out _);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<IInteractionData>> GetInteractions(int? clientId = null,
|
||||
Reference.Game? game = null, CancellationToken token = default)
|
||||
{
|
||||
return (await Task.WhenAll(_interactions.Select(async kvp =>
|
||||
{
|
||||
try
|
||||
{
|
||||
return await kvp.Value(clientId, game, token);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex,
|
||||
"Could not get interaction for interaction {InteractionName} and ClientId {ClientId}", kvp.Key,
|
||||
clientId);
|
||||
return null;
|
||||
}
|
||||
}))).Where(interaction => interaction is not null);
|
||||
}
|
||||
|
||||
public async Task<string> ProcessInteraction(string interactionId, int? clientId = null,
|
||||
Reference.Game? game = null, CancellationToken token = default)
|
||||
{
|
||||
if (!_interactions.ContainsKey(interactionId))
|
||||
{
|
||||
throw new ArgumentException($"Interaction with ID {interactionId} has not been registered");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var interaction = await _interactions[interactionId](clientId, game, token);
|
||||
|
||||
if (interaction.Action is not null)
|
||||
{
|
||||
return await interaction.Action(clientId, game, token);
|
||||
}
|
||||
|
||||
if (interaction.ScriptAction is not null)
|
||||
{
|
||||
foreach (var plugin in _serviceProvider.GetRequiredService<IEnumerable<IPlugin>>())
|
||||
{
|
||||
if (plugin is not ScriptPlugin scriptPlugin || scriptPlugin.Name != interaction.Source)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
return scriptPlugin.ExecuteAction<string>(interaction.ScriptAction, clientId, game, token);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex,
|
||||
"Could not process interaction for interaction {InteractionName} and ClientId {ClientId}",
|
||||
interactionId,
|
||||
clientId);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -7,7 +7,10 @@ using System.Threading.Tasks;
|
||||
using Data.Abstractions;
|
||||
using Data.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SharedLibraryCore;
|
||||
using SharedLibraryCore.Database.Models;
|
||||
using SharedLibraryCore.Dtos;
|
||||
using SharedLibraryCore.Interfaces;
|
||||
using SharedLibraryCore.QueryHelper;
|
||||
@ -19,13 +22,15 @@ public class MetaServiceV2 : IMetaServiceV2
|
||||
{
|
||||
private readonly IDictionary<MetaType, List<dynamic>> _metaActions;
|
||||
private readonly IDatabaseContextFactory _contextFactory;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public MetaServiceV2(ILogger<MetaServiceV2> logger, IDatabaseContextFactory contextFactory)
|
||||
public MetaServiceV2(ILogger<MetaServiceV2> logger, IDatabaseContextFactory contextFactory, IServiceProvider serviceProvider)
|
||||
{
|
||||
_logger = logger;
|
||||
_metaActions = new Dictionary<MetaType, List<dynamic>>();
|
||||
_contextFactory = contextFactory;
|
||||
_serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
public async Task SetPersistentMeta(string metaKey, string metaValue, int clientId,
|
||||
@ -64,6 +69,26 @@ public class MetaServiceV2 : IMetaServiceV2
|
||||
}
|
||||
|
||||
await context.SaveChangesAsync(token);
|
||||
|
||||
|
||||
var manager = _serviceProvider.GetRequiredService<IManager>();
|
||||
var matchingClient = manager.GetActiveClients().FirstOrDefault(client => client.ClientId == clientId);
|
||||
var server = matchingClient?.CurrentServer ?? manager.GetServers().FirstOrDefault();
|
||||
|
||||
if (server is not null)
|
||||
{
|
||||
manager.AddEvent(new GameEvent
|
||||
{
|
||||
Type = GameEvent.EventType.MetaUpdated,
|
||||
Origin = matchingClient ?? new EFClient
|
||||
{
|
||||
ClientId = clientId
|
||||
},
|
||||
Data = metaValue,
|
||||
Extra = metaKey,
|
||||
Owner = server
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public async Task SetPersistentMetaValue<T>(string metaKey, T metaValue, int clientId,
|
||||
@ -207,7 +232,7 @@ public class MetaServiceV2 : IMetaServiceV2
|
||||
|
||||
if (metaValue is null)
|
||||
{
|
||||
_logger.LogWarning("No meta exists for key {Key}, clientId {ClientId}", metaKey, clientId);
|
||||
_logger.LogDebug("No meta exists for key {Key}, clientId {ClientId}", metaKey, clientId);
|
||||
return default;
|
||||
}
|
||||
|
||||
@ -439,61 +464,14 @@ public class MetaServiceV2 : IMetaServiceV2
|
||||
return ProcessInformationMeta(allMeta);
|
||||
}
|
||||
|
||||
var meta = await _metaActions[metaType][0](request) as IEnumerable<T>;
|
||||
var meta = await _metaActions[metaType][0](request, token) as IEnumerable<T>;
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
||||
private static IEnumerable<T> ProcessInformationMeta<T>(IEnumerable<T> meta) where T : IClientMeta
|
||||
{
|
||||
var metaList = meta.ToList();
|
||||
var metaWithColumn = metaList
|
||||
.Where(m => m.Column != null)
|
||||
.ToList();
|
||||
|
||||
var columnGrouping = metaWithColumn
|
||||
.GroupBy(m => m.Column)
|
||||
.ToList();
|
||||
|
||||
var metaToSort = metaList.Except(metaWithColumn).ToList();
|
||||
|
||||
var table = columnGrouping.Select(metaItem => new List<T>(metaItem)).ToList();
|
||||
|
||||
while (metaToSort.Count > 0)
|
||||
{
|
||||
var sortingMeta = metaToSort.First();
|
||||
|
||||
int IndexOfSmallestColumn()
|
||||
{
|
||||
var index = 0;
|
||||
var smallestColumnSize = int.MaxValue;
|
||||
for (var i = 0; i < table.Count; i++)
|
||||
{
|
||||
if (table[i].Count >= smallestColumnSize)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
smallestColumnSize = table[i].Count;
|
||||
index = i;
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
var columnIndex = IndexOfSmallestColumn();
|
||||
|
||||
sortingMeta.Column = columnIndex;
|
||||
sortingMeta.Order = columnGrouping
|
||||
.First(group => group.Key == columnIndex)
|
||||
.Count();
|
||||
|
||||
table[columnIndex].Add(sortingMeta);
|
||||
|
||||
metaToSort.Remove(sortingMeta);
|
||||
}
|
||||
|
||||
return metaList;
|
||||
return meta;
|
||||
}
|
||||
|
||||
private static bool ValidArgs(string key, int clientId) => !string.IsNullOrWhiteSpace(key) && clientId > 0;
|
||||
|
@ -42,6 +42,7 @@ namespace IW4MAdmin.Application.Misc
|
||||
private Engine _scriptEngine;
|
||||
private readonly string _fileName;
|
||||
private readonly SemaphoreSlim _onProcessing = new(1, 1);
|
||||
private readonly SemaphoreSlim _onDvarActionComplete = new(1, 1);
|
||||
private bool _successfullyLoaded;
|
||||
private readonly List<string> _registeredCommandNames;
|
||||
private readonly ILogger _logger;
|
||||
@ -116,7 +117,8 @@ namespace IW4MAdmin.Application.Misc
|
||||
typeof(System.Net.Http.HttpClient).Assembly,
|
||||
typeof(EFClient).Assembly,
|
||||
typeof(Utilities).Assembly,
|
||||
typeof(Encoding).Assembly
|
||||
typeof(Encoding).Assembly,
|
||||
typeof(CancellationTokenSource).Assembly
|
||||
})
|
||||
.CatchClrExceptions()
|
||||
.AddObjectConverter(new PermissionLevelToStringConverter()));
|
||||
@ -276,8 +278,8 @@ namespace IW4MAdmin.Application.Misc
|
||||
{
|
||||
_logger.LogDebug("OnLoad executing for {Name}", Name);
|
||||
_scriptEngine.SetValue("_manager", manager);
|
||||
_scriptEngine.SetValue("getDvar", GetDvarAsync);
|
||||
_scriptEngine.SetValue("setDvar", SetDvarAsync);
|
||||
_scriptEngine.SetValue("getDvar", BeginGetDvar);
|
||||
_scriptEngine.SetValue("setDvar", BeginSetDvar);
|
||||
_scriptEngine.Evaluate("plugin.onLoadAsync(_manager)");
|
||||
|
||||
return Task.CompletedTask;
|
||||
@ -337,13 +339,49 @@ namespace IW4MAdmin.Application.Misc
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public T ExecuteAction<T>(Delegate action, params object[] param)
|
||||
{
|
||||
try
|
||||
{
|
||||
_onProcessing.Wait();
|
||||
var args = param.Select(p => JsValue.FromObject(_scriptEngine, p)).ToArray();
|
||||
var result = action.DynamicInvoke(JsValue.Undefined, args);
|
||||
return (T)(result as JsValue)?.ToObject();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (_onProcessing.CurrentCount == 0)
|
||||
{
|
||||
_onProcessing.Release(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public T WrapDelegate<T>(Delegate act, params object[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
_onProcessing.Wait();
|
||||
return (T)(act.DynamicInvoke(JsValue.Null,
|
||||
args.Select(arg => JsValue.FromObject(_scriptEngine, arg)).ToArray()) as ObjectWrapper)?.ToObject();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (_onProcessing.CurrentCount == 0)
|
||||
{
|
||||
_onProcessing.Release(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// finds declared script commands in the script plugin
|
||||
/// </summary>
|
||||
/// <param name="commands">commands value from jint parser</param>
|
||||
/// <param name="scriptCommandFactory">factory to create the command from</param>
|
||||
/// <returns></returns>
|
||||
private IEnumerable<IManagerCommand> GenerateScriptCommands(JsValue commands, IScriptCommandFactory scriptCommandFactory)
|
||||
private IEnumerable<IManagerCommand> GenerateScriptCommands(JsValue commands,
|
||||
IScriptCommandFactory scriptCommandFactory)
|
||||
{
|
||||
var commandList = new List<IManagerCommand>();
|
||||
|
||||
@ -454,65 +492,86 @@ namespace IW4MAdmin.Application.Misc
|
||||
return commandList;
|
||||
}
|
||||
|
||||
private void GetDvarAsync(Server server, string dvarName, Delegate onCompleted)
|
||||
private void BeginGetDvar(Server server, string dvarName, Delegate onCompleted)
|
||||
{
|
||||
Task.Run<Task>(async () =>
|
||||
void OnComplete(IAsyncResult result)
|
||||
{
|
||||
var tokenSource = new CancellationTokenSource();
|
||||
tokenSource.CancelAfter(TimeSpan.FromSeconds(5));
|
||||
string result = null;
|
||||
var success = true;
|
||||
try
|
||||
{
|
||||
result = (await server.GetDvarAsync<string>(dvarName, token: tokenSource.Token)).Value;
|
||||
}
|
||||
catch
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
var (success, value) = (ValueTuple<bool, string>)result.AsyncState;
|
||||
|
||||
_logger.LogDebug("Waiting for onDvarActionComplete -> get");
|
||||
_onDvarActionComplete.Wait();
|
||||
_logger.LogDebug("Completed wait for onDvarActionComplete -> get");
|
||||
|
||||
await _onProcessing.WaitAsync();
|
||||
try
|
||||
{
|
||||
onCompleted.DynamicInvoke(JsValue.Undefined,
|
||||
new[]
|
||||
{
|
||||
JsValue.FromObject(_scriptEngine, server),
|
||||
JsValue.FromObject(_scriptEngine, dvarName),
|
||||
JsValue.FromObject(_scriptEngine, result),
|
||||
JsValue.FromObject(_scriptEngine, success),
|
||||
JsValue.FromObject(_scriptEngine, value),
|
||||
JsValue.FromObject(_scriptEngine, success)
|
||||
});
|
||||
}
|
||||
catch (JavaScriptException ex)
|
||||
{
|
||||
using (LogContext.PushProperty("Server", server.ToString()))
|
||||
{
|
||||
_logger.LogError(ex, "Could complete BeginGetDvar for {Filename} {@Location}",
|
||||
Path.GetFileName(_fileName), ex.Location);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Could not complete {BeginGetDvar} for {Class}", nameof(BeginGetDvar), Name);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (_onDvarActionComplete.CurrentCount == 0)
|
||||
{
|
||||
_onDvarActionComplete.Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var tokenSource = new CancellationTokenSource();
|
||||
tokenSource.CancelAfter(TimeSpan.FromSeconds(15));
|
||||
|
||||
server.BeginGetDvar(dvarName, result =>
|
||||
{
|
||||
var shouldRelease = false;
|
||||
try
|
||||
{
|
||||
_onProcessing.Wait(tokenSource.Token);
|
||||
shouldRelease = true;
|
||||
}
|
||||
|
||||
finally
|
||||
{
|
||||
if (_onProcessing.CurrentCount == 0)
|
||||
OnComplete(result);
|
||||
|
||||
if (_onProcessing.CurrentCount == 0 && shouldRelease)
|
||||
{
|
||||
_onProcessing.Release();
|
||||
}
|
||||
}
|
||||
});
|
||||
}, tokenSource.Token);
|
||||
}
|
||||
private void SetDvarAsync(Server server, string dvarName, string dvarValue, Delegate onCompleted)
|
||||
{
|
||||
Task.Run<Task>(async () =>
|
||||
|
||||
private void BeginSetDvar(Server server, string dvarName, string dvarValue, Delegate onCompleted)
|
||||
{
|
||||
var tokenSource = new CancellationTokenSource();
|
||||
tokenSource.CancelAfter(TimeSpan.FromSeconds(5));
|
||||
var success = true;
|
||||
tokenSource.CancelAfter(TimeSpan.FromSeconds(15));
|
||||
|
||||
void OnComplete(IAsyncResult result)
|
||||
{
|
||||
try
|
||||
{
|
||||
await server.SetDvarAsync(dvarName, dvarValue, tokenSource.Token);
|
||||
}
|
||||
catch
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
var success = (bool)result.AsyncState;
|
||||
|
||||
await _onProcessing.WaitAsync();
|
||||
try
|
||||
{
|
||||
_logger.LogDebug("Waiting for onDvarActionComplete -> set");
|
||||
_onDvarActionComplete.Wait();
|
||||
_logger.LogDebug("Completed wait for onDvarActionComplete -> set");
|
||||
onCompleted.DynamicInvoke(JsValue.Undefined,
|
||||
new[]
|
||||
{
|
||||
@ -522,15 +581,44 @@ namespace IW4MAdmin.Application.Misc
|
||||
JsValue.FromObject(_scriptEngine, success)
|
||||
});
|
||||
}
|
||||
|
||||
catch (JavaScriptException ex)
|
||||
{
|
||||
using (LogContext.PushProperty("Server", server.ToString()))
|
||||
{
|
||||
_logger.LogError(ex, "Could complete BeginSetDvar for {Filename} {@Location}",
|
||||
Path.GetFileName(_fileName), ex.Location);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Could not complete {BeginSetDvar} for {Class}", nameof(BeginSetDvar), Name);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (_onProcessing.CurrentCount == 0)
|
||||
if (_onDvarActionComplete.CurrentCount == 0)
|
||||
{
|
||||
_onDvarActionComplete.Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
server.BeginSetDvar(dvarName, dvarValue, result =>
|
||||
{
|
||||
var shouldRelease = false;
|
||||
try
|
||||
{
|
||||
_onProcessing.Wait(tokenSource.Token);
|
||||
shouldRelease = true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
OnComplete(result);
|
||||
if (_onProcessing.CurrentCount == 0 && shouldRelease)
|
||||
{
|
||||
_onProcessing.Release();
|
||||
}
|
||||
}
|
||||
});
|
||||
}, tokenSource.Token);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ public class ScriptPluginTimerHelper : IScriptPluginTimerHelper
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogDebug("-Releasing OnTick for timer");
|
||||
_onDependentAction?.Release(1);
|
||||
}
|
||||
private void OnTick()
|
||||
@ -128,7 +128,8 @@ public class ScriptPluginTimerHelper : IScriptPluginTimerHelper
|
||||
_onRunningTick.Reset();
|
||||
|
||||
// the js engine is not thread safe so we need to ensure we're not executing OnTick and OnEventAsync simultaneously
|
||||
_onDependentAction?.WaitAsync().Wait();
|
||||
_onDependentAction?.Wait();
|
||||
_logger.LogDebug("+Running OnTick for timer");
|
||||
var start = DateTime.Now;
|
||||
_jsAction.DynamicInvoke(JsValue.Undefined, new[] { JsValue.Undefined });
|
||||
_logger.LogDebug("OnTick took {Time}ms", (DateTime.Now - start).TotalMilliseconds);
|
||||
|
@ -94,7 +94,8 @@ namespace IW4MAdmin.Application.Misc
|
||||
PeriodBlock = (int) (DateTimeOffset.UtcNow - DateTimeOffset.UnixEpoch).TotalMinutes,
|
||||
ServerId = await server.GetIdForServer(),
|
||||
MapId = await GetOrCreateMap(server.CurrentMap.Name, (Reference.Game) server.GameName, token),
|
||||
ClientCount = server.ClientNum
|
||||
ClientCount = server.ClientNum,
|
||||
ConnectionInterrupted = server.Throttled,
|
||||
}));
|
||||
|
||||
return data;
|
||||
|
@ -5,6 +5,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Data.Abstractions;
|
||||
using Data.Models.Client;
|
||||
using Data.Models.Client.Stats;
|
||||
using Data.Models.Server;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@ -22,18 +23,20 @@ namespace IW4MAdmin.Application.Misc
|
||||
private readonly IDataValueCache<EFServerSnapshot, (int?, DateTime?)> _snapshotCache;
|
||||
private readonly IDataValueCache<EFClient, (int, int)> _serverStatsCache;
|
||||
private readonly IDataValueCache<EFServerSnapshot, List<ClientHistoryInfo>> _clientHistoryCache;
|
||||
private readonly IDataValueCache<EFClientRankingHistory, int> _rankedClientsCache;
|
||||
|
||||
private readonly TimeSpan? _cacheTimeSpan =
|
||||
Utilities.IsDevelopment ? TimeSpan.FromSeconds(30) : (TimeSpan?) TimeSpan.FromMinutes(10);
|
||||
|
||||
public ServerDataViewer(ILogger<ServerDataViewer> logger, IDataValueCache<EFServerSnapshot, (int?, DateTime?)> snapshotCache,
|
||||
IDataValueCache<EFClient, (int, int)> serverStatsCache,
|
||||
IDataValueCache<EFServerSnapshot, List<ClientHistoryInfo>> clientHistoryCache)
|
||||
IDataValueCache<EFServerSnapshot, List<ClientHistoryInfo>> clientHistoryCache, IDataValueCache<EFClientRankingHistory, int> rankedClientsCache)
|
||||
{
|
||||
_logger = logger;
|
||||
_snapshotCache = snapshotCache;
|
||||
_serverStatsCache = serverStatsCache;
|
||||
_clientHistoryCache = clientHistoryCache;
|
||||
_rankedClientsCache = rankedClientsCache;
|
||||
}
|
||||
|
||||
public async Task<(int?, DateTime?)>
|
||||
@ -135,7 +138,9 @@ namespace IW4MAdmin.Application.Misc
|
||||
{
|
||||
snapshot.ServerId,
|
||||
snapshot.CapturedAt,
|
||||
snapshot.ClientCount
|
||||
snapshot.ClientCount,
|
||||
snapshot.ConnectionInterrupted,
|
||||
MapName = snapshot.Map.Name,
|
||||
})
|
||||
.OrderBy(snapshot => snapshot.CapturedAt)
|
||||
.ToListAsync(cancellationToken);
|
||||
@ -143,8 +148,8 @@ namespace IW4MAdmin.Application.Misc
|
||||
return history.GroupBy(snapshot => snapshot.ServerId).Select(byServer => new ClientHistoryInfo
|
||||
{
|
||||
ServerId = byServer.Key,
|
||||
ClientCounts = byServer.Select(snapshot => new ClientCountSnapshot()
|
||||
{Time = snapshot.CapturedAt, ClientCount = snapshot.ClientCount}).ToList()
|
||||
ClientCounts = byServer.Select(snapshot => new ClientCountSnapshot
|
||||
{ Time = snapshot.CapturedAt, ClientCount = snapshot.ClientCount, ConnectionInterrupted = snapshot.ConnectionInterrupted ?? false, Map = snapshot.MapName}).ToList()
|
||||
}).ToList();
|
||||
}, nameof(_clientHistoryCache), TimeSpan.MaxValue);
|
||||
|
||||
@ -158,5 +163,30 @@ namespace IW4MAdmin.Application.Misc
|
||||
return Enumerable.Empty<ClientHistoryInfo>();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<int> RankedClientsCountAsync(long? serverId = null, CancellationToken token = default)
|
||||
{
|
||||
_rankedClientsCache.SetCacheItem(async (set, cancellationToken) =>
|
||||
{
|
||||
var fifteenDaysAgo = DateTime.UtcNow.AddDays(-15);
|
||||
return await set
|
||||
.Where(rating => rating.Newest)
|
||||
.Where(rating => rating.ServerId == serverId)
|
||||
.Where(rating => rating.CreatedDateTime >= fifteenDaysAgo)
|
||||
.Where(rating => rating.Client.Level != EFClient.Permission.Banned)
|
||||
.Where(rating => rating.Ranking != null)
|
||||
.CountAsync(cancellationToken);
|
||||
}, nameof(_rankedClientsCache), serverId is null ? null: new[] { (object)serverId }, _cacheTimeSpan);
|
||||
|
||||
try
|
||||
{
|
||||
return await _rankedClientsCache.GetCacheItem(nameof(_rankedClientsCache), serverId, token);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Could not retrieve data for {Name}", nameof(RankedClientsCountAsync));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -9,40 +9,41 @@ namespace IW4MAdmin.Application.Misc
|
||||
{
|
||||
internal class TokenAuthentication : ITokenAuthentication
|
||||
{
|
||||
private readonly ConcurrentDictionary<long, TokenState> _tokens;
|
||||
private readonly ConcurrentDictionary<int, TokenState> _tokens;
|
||||
private readonly RandomNumberGenerator _random;
|
||||
private static readonly TimeSpan TimeoutPeriod = new TimeSpan(0, 0, 120);
|
||||
private static readonly TimeSpan TimeoutPeriod = new(0, 0, 120);
|
||||
private const short TokenLength = 4;
|
||||
|
||||
public TokenAuthentication()
|
||||
{
|
||||
_tokens = new ConcurrentDictionary<long, TokenState>();
|
||||
_tokens = new ConcurrentDictionary<int, TokenState>();
|
||||
_random = RandomNumberGenerator.Create();
|
||||
}
|
||||
|
||||
public bool AuthorizeToken(long networkId, string token)
|
||||
public bool AuthorizeToken(ITokenIdentifier authInfo)
|
||||
{
|
||||
var authorizeSuccessful = _tokens.ContainsKey(networkId) && _tokens[networkId].Token == token;
|
||||
var authorizeSuccessful = _tokens.ContainsKey(authInfo.ClientId) &&
|
||||
_tokens[authInfo.ClientId].Token == authInfo.Token;
|
||||
|
||||
if (authorizeSuccessful)
|
||||
{
|
||||
_tokens.TryRemove(networkId, out _);
|
||||
_tokens.TryRemove(authInfo.ClientId, out _);
|
||||
}
|
||||
|
||||
return authorizeSuccessful;
|
||||
}
|
||||
|
||||
public TokenState GenerateNextToken(long networkId)
|
||||
public TokenState GenerateNextToken(ITokenIdentifier authInfo)
|
||||
{
|
||||
TokenState state;
|
||||
|
||||
if (_tokens.ContainsKey(networkId))
|
||||
if (_tokens.ContainsKey(authInfo.ClientId))
|
||||
{
|
||||
state = _tokens[networkId];
|
||||
state = _tokens[authInfo.ClientId];
|
||||
|
||||
if ((DateTime.Now - state.RequestTime) > TimeoutPeriod)
|
||||
if (DateTime.Now - state.RequestTime > TimeoutPeriod)
|
||||
{
|
||||
_tokens.TryRemove(networkId, out _);
|
||||
_tokens.TryRemove(authInfo.ClientId, out _);
|
||||
}
|
||||
|
||||
else
|
||||
@ -53,17 +54,16 @@ namespace IW4MAdmin.Application.Misc
|
||||
|
||||
state = new TokenState
|
||||
{
|
||||
NetworkId = networkId,
|
||||
Token = _generateToken(),
|
||||
TokenDuration = TimeoutPeriod
|
||||
};
|
||||
|
||||
_tokens.TryAdd(networkId, state);
|
||||
_tokens.TryAdd(authInfo.ClientId, state);
|
||||
|
||||
// perform some housekeeping so we don't have built up tokens if they're not ever used
|
||||
foreach (var (key, value) in _tokens)
|
||||
{
|
||||
if ((DateTime.Now - value.RequestTime) > TimeoutPeriod)
|
||||
if (DateTime.Now - value.RequestTime > TimeoutPeriod)
|
||||
{
|
||||
_tokens.TryRemove(key, out _);
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Data.Models;
|
||||
using IW4MAdmin.Application.Misc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using static SharedLibraryCore.Server;
|
||||
using ILogger = Microsoft.Extensions.Logging.ILogger;
|
||||
@ -19,6 +20,7 @@ namespace IW4MAdmin.Application.RConParsers
|
||||
public class BaseRConParser : IRConParser
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private static string _botIpIndicator = "00000000.";
|
||||
|
||||
public BaseRConParser(ILogger<BaseRConParser> logger, IParserRegexFactory parserRegexFactory)
|
||||
{
|
||||
@ -51,7 +53,7 @@ namespace IW4MAdmin.Application.RConParsers
|
||||
Configuration.Status.AddMapping(ParserRegex.GroupType.RConName, 5);
|
||||
Configuration.Status.AddMapping(ParserRegex.GroupType.RConIpAddress, 7);
|
||||
|
||||
Configuration.Dvar.Pattern = "^\"(.+)\" is: \"(.+)?\" default: \"(.+)?\"\n(?:latched: \"(.+)?\"\n)? *(.+)$";
|
||||
Configuration.Dvar.Pattern = "^\"(.+)\" is: \"(.+)?\" default: \"(.+)?\"\n?(?:latched: \"(.+)?\"\n?)? *(.+)?$";
|
||||
Configuration.Dvar.AddMapping(ParserRegex.GroupType.RConDvarName, 1);
|
||||
Configuration.Dvar.AddMapping(ParserRegex.GroupType.RConDvarValue, 2);
|
||||
Configuration.Dvar.AddMapping(ParserRegex.GroupType.RConDvarDefaultValue, 3);
|
||||
@ -80,6 +82,7 @@ namespace IW4MAdmin.Application.RConParsers
|
||||
|
||||
public async Task<string[]> ExecuteCommandAsync(IRConConnection connection, string command, CancellationToken token = default)
|
||||
{
|
||||
command = command.FormatMessageForEngine(Configuration);
|
||||
var response = await connection.SendQueryAsync(StaticHelpers.QueryType.COMMAND, command, token);
|
||||
return response.Where(item => item != Configuration.CommandPrefixes.RConResponse).ToArray();
|
||||
}
|
||||
@ -102,7 +105,7 @@ namespace IW4MAdmin.Application.RConParsers
|
||||
lineSplit = Array.Empty<string>();
|
||||
}
|
||||
|
||||
var response = string.Join('\n', lineSplit).TrimEnd('\0');
|
||||
var response = string.Join('\n', lineSplit).Replace("\n", "").TrimEnd('\0');
|
||||
var match = Regex.Match(response, Configuration.Dvar.Pattern);
|
||||
|
||||
if (response.Contains("Unknown command") ||
|
||||
@ -140,6 +143,30 @@ namespace IW4MAdmin.Application.RConParsers
|
||||
};
|
||||
}
|
||||
|
||||
public void BeginGetDvar(IRConConnection connection, string dvarName, AsyncCallback callback, CancellationToken token = default)
|
||||
{
|
||||
GetDvarAsync<string>(connection, dvarName, token: token).ContinueWith(action =>
|
||||
{
|
||||
if (action.Exception is null && !action.IsCanceled)
|
||||
{
|
||||
callback?.Invoke(new AsyncResult
|
||||
{
|
||||
IsCompleted = true,
|
||||
AsyncState = (true, action.Result.Value)
|
||||
});
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
callback?.Invoke(new AsyncResult
|
||||
{
|
||||
IsCompleted = true,
|
||||
AsyncState = (false, (string)null)
|
||||
});
|
||||
}
|
||||
}, CancellationToken.None);
|
||||
}
|
||||
|
||||
public virtual async Task<IStatusResponse> GetStatusAsync(IRConConnection connection, CancellationToken token = default)
|
||||
{
|
||||
var response = await connection.SendQueryAsync(StaticHelpers.QueryType.COMMAND_STATUS, "status", token);
|
||||
@ -149,16 +176,16 @@ namespace IW4MAdmin.Application.RConParsers
|
||||
return new StatusResponse
|
||||
{
|
||||
Clients = ClientsFromStatus(response).ToArray(),
|
||||
Map = GetValueFromStatus<string>(response, ParserRegex.GroupType.RConStatusMap, Configuration.MapStatus.Pattern),
|
||||
GameType = GetValueFromStatus<string>(response, ParserRegex.GroupType.RConStatusGametype, Configuration.GametypeStatus.Pattern),
|
||||
Hostname = GetValueFromStatus<string>(response, ParserRegex.GroupType.RConStatusHostname, Configuration.HostnameStatus.Pattern),
|
||||
MaxClients = GetValueFromStatus<int?>(response, ParserRegex.GroupType.RConStatusMaxPlayers, Configuration.MaxPlayersStatus.Pattern)
|
||||
Map = GetValueFromStatus<string>(response, ParserRegex.GroupType.RConStatusMap, Configuration.MapStatus),
|
||||
GameType = GetValueFromStatus<string>(response, ParserRegex.GroupType.RConStatusGametype, Configuration.GametypeStatus),
|
||||
Hostname = GetValueFromStatus<string>(response, ParserRegex.GroupType.RConStatusHostname, Configuration.HostnameStatus),
|
||||
MaxClients = GetValueFromStatus<int?>(response, ParserRegex.GroupType.RConStatusMaxPlayers, Configuration.MaxPlayersStatus)
|
||||
};
|
||||
}
|
||||
|
||||
private T GetValueFromStatus<T>(IEnumerable<string> response, ParserRegex.GroupType groupType, string groupPattern)
|
||||
private T GetValueFromStatus<T>(IEnumerable<string> response, ParserRegex.GroupType groupType, ParserRegex parserRegex)
|
||||
{
|
||||
if (string.IsNullOrEmpty(groupPattern))
|
||||
if (string.IsNullOrEmpty(parserRegex.Pattern))
|
||||
{
|
||||
return default;
|
||||
}
|
||||
@ -166,10 +193,10 @@ namespace IW4MAdmin.Application.RConParsers
|
||||
string value = null;
|
||||
foreach (var line in response)
|
||||
{
|
||||
var regex = Regex.Match(line, groupPattern);
|
||||
if (regex.Success)
|
||||
var regex = Regex.Match(line, parserRegex.Pattern);
|
||||
if (regex.Success && parserRegex.GroupMapping.ContainsKey(groupType))
|
||||
{
|
||||
value = regex.Groups[Configuration.MapStatus.GroupMapping[groupType]].ToString();
|
||||
value = regex.Groups[parserRegex.GroupMapping[groupType]].ToString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -195,6 +222,31 @@ namespace IW4MAdmin.Application.RConParsers
|
||||
return (await connection.SendQueryAsync(StaticHelpers.QueryType.SET_DVAR, dvarString, token)).Length > 0;
|
||||
}
|
||||
|
||||
public void BeginSetDvar(IRConConnection connection, string dvarName, object dvarValue, AsyncCallback callback,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
SetDvarAsync(connection, dvarName, dvarValue, token).ContinueWith(action =>
|
||||
{
|
||||
if (action.Exception is null && !action.IsCanceled)
|
||||
{
|
||||
callback?.Invoke(new AsyncResult
|
||||
{
|
||||
IsCompleted = true,
|
||||
AsyncState = true
|
||||
});
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
callback?.Invoke(new AsyncResult
|
||||
{
|
||||
IsCompleted = true,
|
||||
AsyncState = false
|
||||
});
|
||||
}
|
||||
}, CancellationToken.None);
|
||||
}
|
||||
|
||||
private List<EFClient> ClientsFromStatus(string[] Status)
|
||||
{
|
||||
List<EFClient> StatusPlayers = new List<EFClient>();
|
||||
@ -239,8 +291,15 @@ namespace IW4MAdmin.Application.RConParsers
|
||||
long networkId;
|
||||
var name = match.Values[Configuration.Status.GroupMapping[ParserRegex.GroupType.RConName]].TrimNewLine();
|
||||
string networkIdString;
|
||||
|
||||
var ip = match.Values[Configuration.Status.GroupMapping[ParserRegex.GroupType.RConIpAddress]].Split(':')[0].ConvertToIP();
|
||||
|
||||
if (match.Values[Configuration.Status.GroupMapping[ParserRegex.GroupType.RConIpAddress]]
|
||||
.Contains(_botIpIndicator))
|
||||
{
|
||||
ip = System.Net.IPAddress.Broadcast.ToString().ConvertToIP();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
networkIdString = match.Values[Configuration.Status.GroupMapping[ParserRegex.GroupType.RConNetworkId]];
|
||||
@ -255,9 +314,9 @@ namespace IW4MAdmin.Application.RConParsers
|
||||
continue;
|
||||
}
|
||||
|
||||
var client = new EFClient()
|
||||
var client = new EFClient
|
||||
{
|
||||
CurrentAlias = new EFAlias()
|
||||
CurrentAlias = new EFAlias
|
||||
{
|
||||
Name = name,
|
||||
IPAddress = ip
|
||||
@ -309,15 +368,28 @@ namespace IW4MAdmin.Application.RConParsers
|
||||
(T)Convert.ChangeType(Configuration.DefaultDvarValues[dvarName], typeof(T)) :
|
||||
default;
|
||||
|
||||
public TimeSpan OverrideTimeoutForCommand(string command)
|
||||
public TimeSpan? OverrideTimeoutForCommand(string command)
|
||||
{
|
||||
if (command.Contains("map_rotate", StringComparison.InvariantCultureIgnoreCase) ||
|
||||
command.StartsWith("map ", StringComparison.InvariantCultureIgnoreCase))
|
||||
if (string.IsNullOrEmpty(command))
|
||||
{
|
||||
return TimeSpan.FromSeconds(30);
|
||||
}
|
||||
|
||||
return TimeSpan.Zero;
|
||||
}
|
||||
|
||||
var commandToken = command.Split(' ', StringSplitOptions.RemoveEmptyEntries).First().ToLower();
|
||||
|
||||
if (!Configuration.OverrideCommandTimeouts.ContainsKey(commandToken))
|
||||
{
|
||||
return TimeSpan.Zero;
|
||||
}
|
||||
|
||||
var timeoutValue = Configuration.OverrideCommandTimeouts[commandToken];
|
||||
|
||||
if (timeoutValue.HasValue && timeoutValue.Value != 0) // JINT doesn't seem to be able to properly set nulls on dictionaries
|
||||
{
|
||||
return TimeSpan.FromSeconds(timeoutValue.Value);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,12 +26,14 @@ namespace IW4MAdmin.Application.RConParsers
|
||||
public NumberStyles GuidNumberStyle { get; set; } = NumberStyles.HexNumber;
|
||||
public IDictionary<string, string> OverrideDvarNameMapping { get; set; } = new Dictionary<string, string>();
|
||||
public IDictionary<string, string> DefaultDvarValues { get; set; } = new Dictionary<string, string>();
|
||||
public IDictionary<string, int?> OverrideCommandTimeouts { get; set; } = new Dictionary<string, int?>();
|
||||
public int NoticeMaximumLines { get; set; } = 8;
|
||||
public int NoticeMaxCharactersPerLine { get; set; } = 50;
|
||||
public string NoticeLineSeparator { get; set; } = Environment.NewLine;
|
||||
public int? DefaultRConPort { get; set; }
|
||||
public string DefaultInstallationDirectoryHint { get; set; }
|
||||
public short FloodProtectInterval { get; set; } = 750;
|
||||
public bool ShouldRemoveDiacritics { get; set; }
|
||||
|
||||
public ColorCodeMapping ColorCodeMapping { get; set; } = new ColorCodeMapping
|
||||
{
|
||||
@ -46,7 +48,7 @@ namespace IW4MAdmin.Application.RConParsers
|
||||
{ColorCodes.White.ToString(), "^7"},
|
||||
{ColorCodes.Map.ToString(), "^8"},
|
||||
{ColorCodes.Grey.ToString(), "^9"},
|
||||
{ColorCodes.Wildcard.ToString(), ":^"},
|
||||
{ColorCodes.Wildcard.ToString(), "^:"}
|
||||
};
|
||||
|
||||
public DynamicRConParserConfiguration(IParserRegexFactory parserRegexFactory)
|
||||
@ -58,6 +60,25 @@ namespace IW4MAdmin.Application.RConParsers
|
||||
StatusHeader = parserRegexFactory.CreateParserRegex();
|
||||
HostnameStatus = parserRegexFactory.CreateParserRegex();
|
||||
MaxPlayersStatus = parserRegexFactory.CreateParserRegex();
|
||||
|
||||
|
||||
const string mapRotateCommand = "map_rotate";
|
||||
const string mapCommand = "map";
|
||||
const string fastRestartCommand = "fast_restart";
|
||||
const string quitCommand = "quit";
|
||||
|
||||
foreach (var command in new[] { mapRotateCommand, mapCommand, fastRestartCommand})
|
||||
{
|
||||
if (!OverrideCommandTimeouts.ContainsKey(command))
|
||||
{
|
||||
OverrideCommandTimeouts.Add(command, 45);
|
||||
}
|
||||
}
|
||||
|
||||
if (!OverrideCommandTimeouts.ContainsKey(quitCommand))
|
||||
{
|
||||
OverrideCommandTimeouts.Add(quitCommand, 0); // we don't want to wait for a response when we quit the server
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
BIN
Application/Resources/GeoLite2-Country.mmdb
Normal file
BIN
Application/Resources/GeoLite2-Country.mmdb
Normal file
Binary file not shown.
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@ -9,6 +10,11 @@ namespace Data.Abstractions
|
||||
{
|
||||
void SetCacheItem(Func<DbSet<TEntityType>, CancellationToken, Task<TReturnType>> itemGetter, string keyName,
|
||||
TimeSpan? expirationTime = null, bool autoRefresh = false);
|
||||
|
||||
void SetCacheItem(Func<DbSet<TEntityType>, CancellationToken, Task<TReturnType>> itemGetter, string keyName,
|
||||
IEnumerable<object> ids = null, TimeSpan? expirationTime = null, bool autoRefresh = false);
|
||||
|
||||
Task<TReturnType> GetCacheItem(string keyName, CancellationToken token = default);
|
||||
Task<TReturnType> GetCacheItem(string keyName, object id = null, CancellationToken token = default);
|
||||
}
|
||||
}
|
@ -85,7 +85,15 @@ namespace Data.Context
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
// make network id unique
|
||||
modelBuilder.Entity<EFClient>(entity => { entity.HasIndex(e => e.NetworkId).IsUnique(); });
|
||||
modelBuilder.Entity<EFClient>(entity =>
|
||||
{
|
||||
entity.HasIndex(e => e.NetworkId);
|
||||
entity.HasAlternateKey(client => new
|
||||
{
|
||||
client.NetworkId,
|
||||
client.GameName
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity<EFPenalty>(entity =>
|
||||
{
|
||||
@ -120,6 +128,9 @@ namespace Data.Context
|
||||
ent.Property(_alias => _alias.SearchableName).HasMaxLength(24);
|
||||
ent.HasIndex(_alias => _alias.SearchableName);
|
||||
ent.HasIndex(_alias => new {_alias.Name, _alias.IPAddress});
|
||||
ent.Property(alias => alias.SearchableIPAddress)
|
||||
.HasComputedColumnSql(@"((IPAddress & 255) || '.' || ((IPAddress >> 8) & 255)) || '.' || ((IPAddress >> 16) & 255) || '.' || ((IPAddress >> 24) & 255)", stored: true);
|
||||
ent.HasIndex(alias => alias.SearchableIPAddress);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<EFMeta>(ent =>
|
||||
|
@ -8,7 +8,7 @@
|
||||
<PackageId>RaidMax.IW4MAdmin.Data</PackageId>
|
||||
<Title>RaidMax.IW4MAdmin.Data</Title>
|
||||
<Authors />
|
||||
<PackageVersion>1.2.0</PackageVersion>
|
||||
<PackageVersion>2022.10.11.1</PackageVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Data.Abstractions;
|
||||
@ -15,8 +17,8 @@ namespace Data.Helpers
|
||||
private readonly ILogger _logger;
|
||||
private readonly IDatabaseContextFactory _contextFactory;
|
||||
|
||||
private readonly ConcurrentDictionary<string, CacheState<TReturnType>> _cacheStates =
|
||||
new ConcurrentDictionary<string, CacheState<TReturnType>>();
|
||||
private readonly ConcurrentDictionary<string, Dictionary<object, CacheState<TReturnType>>> _cacheStates = new();
|
||||
private readonly object _defaultKey = new();
|
||||
|
||||
private bool _autoRefresh;
|
||||
private const int DefaultExpireMinutes = 15;
|
||||
@ -51,10 +53,24 @@ namespace Data.Helpers
|
||||
public void SetCacheItem(Func<DbSet<TEntityType>, CancellationToken, Task<TReturnType>> getter, string key,
|
||||
TimeSpan? expirationTime = null, bool autoRefresh = false)
|
||||
{
|
||||
if (_cacheStates.ContainsKey(key))
|
||||
SetCacheItem(getter, key, null, expirationTime, autoRefresh);
|
||||
}
|
||||
|
||||
public void SetCacheItem(Func<DbSet<TEntityType>, CancellationToken, Task<TReturnType>> getter, string key,
|
||||
IEnumerable<object> ids = null, TimeSpan? expirationTime = null, bool autoRefresh = false)
|
||||
{
|
||||
_logger.LogDebug("Cache key {Key} is already added", key);
|
||||
return;
|
||||
ids ??= new[] { _defaultKey };
|
||||
|
||||
if (!_cacheStates.ContainsKey(key))
|
||||
{
|
||||
_cacheStates.TryAdd(key, new Dictionary<object, CacheState<TReturnType>>());
|
||||
}
|
||||
|
||||
foreach (var id in ids)
|
||||
{
|
||||
if (_cacheStates[key].ContainsKey(id))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var state = new CacheState<TReturnType>
|
||||
@ -64,9 +80,10 @@ namespace Data.Helpers
|
||||
ExpirationTime = expirationTime ?? TimeSpan.FromMinutes(DefaultExpireMinutes)
|
||||
};
|
||||
|
||||
_cacheStates[key].Add(id, state);
|
||||
|
||||
_autoRefresh = autoRefresh;
|
||||
|
||||
_cacheStates.TryAdd(key, state);
|
||||
|
||||
if (!_autoRefresh || expirationTime == TimeSpan.MaxValue)
|
||||
{
|
||||
@ -77,15 +94,20 @@ namespace Data.Helpers
|
||||
_timer.Elapsed += async (sender, args) => await RunCacheUpdate(state, CancellationToken.None);
|
||||
_timer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<TReturnType> GetCacheItem(string keyName, CancellationToken cancellationToken = default)
|
||||
public async Task<TReturnType> GetCacheItem(string keyName, CancellationToken cancellationToken = default) =>
|
||||
await GetCacheItem(keyName, null, cancellationToken);
|
||||
|
||||
public async Task<TReturnType> GetCacheItem(string keyName, object id = null,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (!_cacheStates.ContainsKey(keyName))
|
||||
{
|
||||
throw new ArgumentException("No cache found for key {key}", keyName);
|
||||
}
|
||||
|
||||
var state = _cacheStates[keyName];
|
||||
var state = id is null ? _cacheStates[keyName].Values.First() : _cacheStates[keyName][id];
|
||||
|
||||
// when auto refresh is off we want to check the expiration and value
|
||||
// when auto refresh is on, we want to only check the value, because it'll be refreshed automatically
|
||||
|
1626
Data/Migrations/MySql/20220329213440_AddConnectionInterruptedToEFServerSnapshot.Designer.cs
generated
Normal file
1626
Data/Migrations/MySql/20220329213440_AddConnectionInterruptedToEFServerSnapshot.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,25 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Data.Migrations.MySql
|
||||
{
|
||||
public partial class AddConnectionInterruptedToEFServerSnapshot : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "ConnectionInterrupted",
|
||||
table: "EFServerSnapshot",
|
||||
type: "tinyint(1)",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ConnectionInterrupted",
|
||||
table: "EFServerSnapshot");
|
||||
}
|
||||
}
|
||||
}
|
1631
Data/Migrations/MySql/20220404151444_AddSearchableIPToEFAlias.Designer.cs
generated
Normal file
1631
Data/Migrations/MySql/20220404151444_AddSearchableIPToEFAlias.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,28 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Data.Migrations.MySql
|
||||
{
|
||||
public partial class AddSearchableIPToEFAlias : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "SearchableIPAddress",
|
||||
table: "EFAlias",
|
||||
type: "longtext",
|
||||
nullable: true,
|
||||
computedColumnSql: "CONCAT((IPAddress & 255), \".\", ((IPAddress >> 8) & 255), \".\", ((IPAddress >> 16) & 255), \".\", ((IPAddress >> 24) & 255))",
|
||||
stored: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "SearchableIPAddress",
|
||||
table: "EFAlias");
|
||||
}
|
||||
}
|
||||
}
|
1633
Data/Migrations/MySql/20220404192417_AddIndexToSearchableIPToEFAlias.Designer.cs
generated
Normal file
1633
Data/Migrations/MySql/20220404192417_AddIndexToSearchableIPToEFAlias.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,24 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Data.Migrations.MySql
|
||||
{
|
||||
public partial class AddIndexToSearchableIPToEFAlias : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFAlias_SearchableIPAddress",
|
||||
table: "EFAlias",
|
||||
column: "SearchableIPAddress");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_EFAlias_SearchableIPAddress",
|
||||
table: "EFAlias");
|
||||
}
|
||||
}
|
||||
}
|
1636
Data/Migrations/MySql/20220422202702_AddGameToEFClient.Designer.cs
generated
Normal file
1636
Data/Migrations/MySql/20220422202702_AddGameToEFClient.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
25
Data/Migrations/MySql/20220422202702_AddGameToEFClient.cs
Normal file
25
Data/Migrations/MySql/20220422202702_AddGameToEFClient.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Data.Migrations.MySql
|
||||
{
|
||||
public partial class AddGameToEFClient : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "GameName",
|
||||
table: "EFClients",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "GameName",
|
||||
table: "EFClients");
|
||||
}
|
||||
}
|
||||
}
|
1638
Data/Migrations/MySql/20220609135128_AddIndexToEFRankingHistoryCreatedDatetime.Designer.cs
generated
Normal file
1638
Data/Migrations/MySql/20220609135128_AddIndexToEFRankingHistoryCreatedDatetime.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,24 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Data.Migrations.MySql
|
||||
{
|
||||
public partial class AddIndexToEFRankingHistoryCreatedDatetime : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFClientRankingHistory_CreatedDateTime",
|
||||
table: "EFClientRankingHistory",
|
||||
column: "CreatedDateTime");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_EFClientRankingHistory_CreatedDateTime",
|
||||
table: "EFClientRankingHistory");
|
||||
}
|
||||
}
|
||||
}
|
1639
Data/Migrations/MySql/20220613192602_AddAlternateKeyToEFClients.Designer.cs
generated
Normal file
1639
Data/Migrations/MySql/20220613192602_AddAlternateKeyToEFClients.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,63 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Data.Migrations.MySql
|
||||
{
|
||||
public partial class AddAlternateKeyToEFClients : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_EFClients_NetworkId",
|
||||
table: "EFClients");
|
||||
|
||||
migrationBuilder.Sql("UPDATE `EFClients` set `GameName` = 0 WHERE `GameName` IS NULL");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "GameName",
|
||||
table: "EFClients",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "int",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AddUniqueConstraint(
|
||||
name: "AK_EFClients_NetworkId_GameName",
|
||||
table: "EFClients",
|
||||
columns: new[] { "NetworkId", "GameName" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFClients_NetworkId",
|
||||
table: "EFClients",
|
||||
column: "NetworkId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropUniqueConstraint(
|
||||
name: "AK_EFClients_NetworkId_GameName",
|
||||
table: "EFClients");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_EFClients_NetworkId",
|
||||
table: "EFClients");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "GameName",
|
||||
table: "EFClients",
|
||||
type: "int",
|
||||
nullable: true,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "int");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFClients_NetworkId",
|
||||
table: "EFClients",
|
||||
column: "NetworkId",
|
||||
unique: true);
|
||||
}
|
||||
}
|
||||
}
|
1639
Data/Migrations/MySql/20220616224602_AddDescendingTimeSentIndexEFClientMessages.Designer.cs
generated
Normal file
1639
Data/Migrations/MySql/20220616224602_AddDescendingTimeSentIndexEFClientMessages.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Data.Migrations.MySql
|
||||
{
|
||||
public partial class AddDescendingTimeSentIndexEFClientMessages : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
try
|
||||
{
|
||||
migrationBuilder.Sql(@"create index IX_EFClientMessages_TimeSentDesc on EFClientMessages (TimeSent desc);");
|
||||
}
|
||||
catch
|
||||
{
|
||||
migrationBuilder.Sql(@"create index IX_EFClientMessages_TimeSentDesc on efclientmessages (TimeSent desc);");
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.Sql(@"drop index IX_EFClientMessages_TimeSentDesc on EFClientMessages;");
|
||||
}
|
||||
}
|
||||
}
|
@ -64,6 +64,9 @@ namespace Data.Migrations.MySql
|
||||
b.Property<DateTime>("FirstConnection")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<int>("GameName")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("LastConnection")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
@ -87,12 +90,13 @@ namespace Data.Migrations.MySql
|
||||
|
||||
b.HasKey("ClientId");
|
||||
|
||||
b.HasAlternateKey("NetworkId", "GameName");
|
||||
|
||||
b.HasIndex("AliasLinkId");
|
||||
|
||||
b.HasIndex("CurrentAliasId");
|
||||
|
||||
b.HasIndex("NetworkId")
|
||||
.IsUnique();
|
||||
b.HasIndex("NetworkId");
|
||||
|
||||
b.ToTable("EFClients", (string)null);
|
||||
});
|
||||
@ -453,6 +457,8 @@ namespace Data.Migrations.MySql
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("CreatedDateTime");
|
||||
|
||||
b.HasIndex("Ranking");
|
||||
|
||||
b.HasIndex("ServerId");
|
||||
@ -804,6 +810,11 @@ namespace Data.Migrations.MySql
|
||||
.HasMaxLength(24)
|
||||
.HasColumnType("varchar(24)");
|
||||
|
||||
b.Property<string>("SearchableIPAddress")
|
||||
.ValueGeneratedOnAddOrUpdate()
|
||||
.HasColumnType("varchar(255)")
|
||||
.HasComputedColumnSql("((IPAddress & 255) || '.' || ((IPAddress >> 8) & 255)) || '.' || ((IPAddress >> 16) & 255) || '.' || ((IPAddress >> 24) & 255)", true);
|
||||
|
||||
b.Property<string>("SearchableName")
|
||||
.HasMaxLength(24)
|
||||
.HasColumnType("varchar(24)");
|
||||
@ -816,6 +827,8 @@ namespace Data.Migrations.MySql
|
||||
|
||||
b.HasIndex("Name");
|
||||
|
||||
b.HasIndex("SearchableIPAddress");
|
||||
|
||||
b.HasIndex("SearchableName");
|
||||
|
||||
b.HasIndex("Name", "IPAddress");
|
||||
@ -1081,6 +1094,9 @@ namespace Data.Migrations.MySql
|
||||
b.Property<int>("ClientCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<bool?>("ConnectionInterrupted")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<int>("MapId")
|
||||
.HasColumnType("int");
|
||||
|
||||
|
1683
Data/Migrations/Postgresql/20220329213521_AddConnectionInterruptedToEFServerSnapshot.Designer.cs
generated
Normal file
1683
Data/Migrations/Postgresql/20220329213521_AddConnectionInterruptedToEFServerSnapshot.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,25 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Data.Migrations.Postgresql
|
||||
{
|
||||
public partial class AddConnectionInterruptedToEFServerSnapshot : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "ConnectionInterrupted",
|
||||
table: "EFServerSnapshot",
|
||||
type: "boolean",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ConnectionInterrupted",
|
||||
table: "EFServerSnapshot");
|
||||
}
|
||||
}
|
||||
}
|
1688
Data/Migrations/Postgresql/20220404185627_AddSearchableIPToEFAlias.Designer.cs
generated
Normal file
1688
Data/Migrations/Postgresql/20220404185627_AddSearchableIPToEFAlias.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,27 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Data.Migrations.Postgresql
|
||||
{
|
||||
public partial class AddSearchableIPToEFAlias : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "SearchableIPAddress",
|
||||
table: "EFAlias",
|
||||
type: "text",
|
||||
nullable: true,
|
||||
computedColumnSql: "CASE WHEN \"IPAddress\" IS NULL THEN 'NULL'::text ELSE (\"IPAddress\" & 255)::text || '.'::text || ((\"IPAddress\" >> 8) & 255)::text || '.'::text || ((\"IPAddress\" >> 16) & 255)::text || '.'::text || ((\"IPAddress\" >> 24) & 255)::text END",
|
||||
stored: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "SearchableIPAddress",
|
||||
table: "EFAlias");
|
||||
}
|
||||
}
|
||||
}
|
1690
Data/Migrations/Postgresql/20220404192553_AddIndexToSearchableIPToEFAlias.Designer.cs
generated
Normal file
1690
Data/Migrations/Postgresql/20220404192553_AddIndexToSearchableIPToEFAlias.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,24 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Data.Migrations.Postgresql
|
||||
{
|
||||
public partial class AddIndexToSearchableIPToEFAlias : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFAlias_SearchableIPAddress",
|
||||
table: "EFAlias",
|
||||
column: "SearchableIPAddress");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_EFAlias_SearchableIPAddress",
|
||||
table: "EFAlias");
|
||||
}
|
||||
}
|
||||
}
|
1693
Data/Migrations/Postgresql/20220422203121_AddGameToEFClient.Designer.cs
generated
Normal file
1693
Data/Migrations/Postgresql/20220422203121_AddGameToEFClient.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,25 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Data.Migrations.Postgresql
|
||||
{
|
||||
public partial class AddGameToEFClient : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "GameName",
|
||||
table: "EFClients",
|
||||
type: "integer",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "GameName",
|
||||
table: "EFClients");
|
||||
}
|
||||
}
|
||||
}
|
1695
Data/Migrations/Postgresql/20220609135210_AddIndexToEFRankingHistoryCreatedDatetime.Designer.cs
generated
Normal file
1695
Data/Migrations/Postgresql/20220609135210_AddIndexToEFRankingHistoryCreatedDatetime.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,24 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Data.Migrations.Postgresql
|
||||
{
|
||||
public partial class AddIndexToEFRankingHistoryCreatedDatetime : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFClientRankingHistory_CreatedDateTime",
|
||||
table: "EFClientRankingHistory",
|
||||
column: "CreatedDateTime");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_EFClientRankingHistory_CreatedDateTime",
|
||||
table: "EFClientRankingHistory");
|
||||
}
|
||||
}
|
||||
}
|
1696
Data/Migrations/Postgresql/20220613181913_AddAlternateKeyToEFClients.Designer.cs
generated
Normal file
1696
Data/Migrations/Postgresql/20220613181913_AddAlternateKeyToEFClients.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,63 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Data.Migrations.Postgresql
|
||||
{
|
||||
public partial class AddAlternateKeyToEFClients : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_EFClients_NetworkId",
|
||||
table: "EFClients");
|
||||
|
||||
migrationBuilder.Sql("UPDATE \"EFClients\" SET \"GameName\" = 0 WHERE \"GameName\" IS NULL");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "GameName",
|
||||
table: "EFClients",
|
||||
type: "integer",
|
||||
nullable: false,
|
||||
defaultValue: 0,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "integer",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AddUniqueConstraint(
|
||||
name: "AK_EFClients_NetworkId_GameName",
|
||||
table: "EFClients",
|
||||
columns: new[] { "NetworkId", "GameName" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFClients_NetworkId",
|
||||
table: "EFClients",
|
||||
column: "NetworkId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropUniqueConstraint(
|
||||
name: "AK_EFClients_NetworkId_GameName",
|
||||
table: "EFClients");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_EFClients_NetworkId",
|
||||
table: "EFClients");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "GameName",
|
||||
table: "EFClients",
|
||||
type: "integer",
|
||||
nullable: true,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "integer");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFClients_NetworkId",
|
||||
table: "EFClients",
|
||||
column: "NetworkId",
|
||||
unique: true);
|
||||
}
|
||||
}
|
||||
}
|
1696
Data/Migrations/Postgresql/20220616224145_AddDescendingTimeSentIndexEFClientMessages.Designer.cs
generated
Normal file
1696
Data/Migrations/Postgresql/20220616224145_AddDescendingTimeSentIndexEFClientMessages.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,24 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Data.Migrations.Postgresql
|
||||
{
|
||||
public partial class AddDescendingTimeSentIndexEFClientMessages : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.Sql(
|
||||
@"CREATE INDEX""IX_EFClientMessages_TimeSentDesc""
|
||||
ON public.""EFClientMessages"" USING btree
|
||||
(""TimeSent"" DESC NULLS LAST)
|
||||
TABLESPACE pg_default;"
|
||||
);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.Sql(@"DROP INDEX public.""IX_EFClientMessages_TimeSentDesc""");
|
||||
}
|
||||
}
|
||||
}
|
@ -71,6 +71,9 @@ namespace Data.Migrations.Postgresql
|
||||
b.Property<DateTime>("FirstConnection")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int>("GameName")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("LastConnection")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
@ -94,12 +97,13 @@ namespace Data.Migrations.Postgresql
|
||||
|
||||
b.HasKey("ClientId");
|
||||
|
||||
b.HasAlternateKey("NetworkId", "GameName");
|
||||
|
||||
b.HasIndex("AliasLinkId");
|
||||
|
||||
b.HasIndex("CurrentAliasId");
|
||||
|
||||
b.HasIndex("NetworkId")
|
||||
.IsUnique();
|
||||
b.HasIndex("NetworkId");
|
||||
|
||||
b.ToTable("EFClients", (string)null);
|
||||
});
|
||||
@ -472,6 +476,8 @@ namespace Data.Migrations.Postgresql
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("CreatedDateTime");
|
||||
|
||||
b.HasIndex("Ranking");
|
||||
|
||||
b.HasIndex("ServerId");
|
||||
@ -843,6 +849,11 @@ namespace Data.Migrations.Postgresql
|
||||
.HasMaxLength(24)
|
||||
.HasColumnType("character varying(24)");
|
||||
|
||||
b.Property<string>("SearchableIPAddress")
|
||||
.ValueGeneratedOnAddOrUpdate()
|
||||
.HasColumnType("text")
|
||||
.HasComputedColumnSql("((IPAddress & 255) || '.' || ((IPAddress >> 8) & 255)) || '.' || ((IPAddress >> 16) & 255) || '.' || ((IPAddress >> 24) & 255)", true);
|
||||
|
||||
b.Property<string>("SearchableName")
|
||||
.HasMaxLength(24)
|
||||
.HasColumnType("character varying(24)");
|
||||
@ -855,6 +866,8 @@ namespace Data.Migrations.Postgresql
|
||||
|
||||
b.HasIndex("Name");
|
||||
|
||||
b.HasIndex("SearchableIPAddress");
|
||||
|
||||
b.HasIndex("SearchableName");
|
||||
|
||||
b.HasIndex("Name", "IPAddress");
|
||||
@ -1134,6 +1147,9 @@ namespace Data.Migrations.Postgresql
|
||||
b.Property<int>("ClientCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool?>("ConnectionInterrupted")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int>("MapId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
|
1624
Data/Migrations/Sqlite/20220329163928_AddConnectionInterruptedToEFServerSnapshot.Designer.cs
generated
Normal file
1624
Data/Migrations/Sqlite/20220329163928_AddConnectionInterruptedToEFServerSnapshot.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,25 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Data.Migrations.Sqlite
|
||||
{
|
||||
public partial class AddConnectionInterruptedToEFServerSnapshot : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "ConnectionInterrupted",
|
||||
table: "EFServerSnapshot",
|
||||
type: "INTEGER",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ConnectionInterrupted",
|
||||
table: "EFServerSnapshot");
|
||||
}
|
||||
}
|
||||
}
|
1629
Data/Migrations/Sqlite/20220402211115_AddSearchableIPToEFAlias.Designer.cs
generated
Normal file
1629
Data/Migrations/Sqlite/20220402211115_AddSearchableIPToEFAlias.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,26 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Data.Migrations.Sqlite
|
||||
{
|
||||
public partial class AddSearchableIPToEFAlias : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "SearchableIPAddress",
|
||||
table: "EFAlias",
|
||||
type: "TEXT",
|
||||
nullable: true,
|
||||
computedColumnSql: "((IPAddress & 255) || '.' || ((IPAddress >> 8) & 255)) || '.' || ((IPAddress >> 16) & 255) || '.' || ((IPAddress >> 24) & 255)");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "SearchableIPAddress",
|
||||
table: "EFAlias");
|
||||
}
|
||||
}
|
||||
}
|
1631
Data/Migrations/Sqlite/20220404192319_AddIndexToSearchableIPToEFAlias.Designer.cs
generated
Normal file
1631
Data/Migrations/Sqlite/20220404192319_AddIndexToSearchableIPToEFAlias.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,24 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Data.Migrations.Sqlite
|
||||
{
|
||||
public partial class AddIndexToSearchableIPToEFAlias : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFAlias_SearchableIPAddress",
|
||||
table: "EFAlias",
|
||||
column: "SearchableIPAddress");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_EFAlias_SearchableIPAddress",
|
||||
table: "EFAlias");
|
||||
}
|
||||
}
|
||||
}
|
1634
Data/Migrations/Sqlite/20220422202315_AddGameToEFClient.Designer.cs
generated
Normal file
1634
Data/Migrations/Sqlite/20220422202315_AddGameToEFClient.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
25
Data/Migrations/Sqlite/20220422202315_AddGameToEFClient.cs
Normal file
25
Data/Migrations/Sqlite/20220422202315_AddGameToEFClient.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Data.Migrations.Sqlite
|
||||
{
|
||||
public partial class AddGameToEFClient : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "GameName",
|
||||
table: "EFClients",
|
||||
type: "INTEGER",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "GameName",
|
||||
table: "EFClients");
|
||||
}
|
||||
}
|
||||
}
|
1636
Data/Migrations/Sqlite/20220609022511_AddIndexToEFRankingHistoryCreatedDatetime.Designer.cs
generated
Normal file
1636
Data/Migrations/Sqlite/20220609022511_AddIndexToEFRankingHistoryCreatedDatetime.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,24 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Data.Migrations.Sqlite
|
||||
{
|
||||
public partial class AddIndexToEFRankingHistoryCreatedDatetime : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFClientRankingHistory_CreatedDateTime",
|
||||
table: "EFClientRankingHistory",
|
||||
column: "CreatedDateTime");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_EFClientRankingHistory_CreatedDateTime",
|
||||
table: "EFClientRankingHistory");
|
||||
}
|
||||
}
|
||||
}
|
1637
Data/Migrations/Sqlite/20220613160952_AddAlternateKeyToEFClients.Designer.cs
generated
Normal file
1637
Data/Migrations/Sqlite/20220613160952_AddAlternateKeyToEFClients.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,61 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Data.Migrations.Sqlite
|
||||
{
|
||||
public partial class AddAlternateKeyToEFClients : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_EFClients_NetworkId",
|
||||
table: "EFClients");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "GameName",
|
||||
table: "EFClients",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
defaultValue: 0,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "INTEGER",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AddUniqueConstraint(
|
||||
name: "AK_EFClients_NetworkId_GameName",
|
||||
table: "EFClients",
|
||||
columns: new[] { "NetworkId", "GameName" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFClients_NetworkId",
|
||||
table: "EFClients",
|
||||
column: "NetworkId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropUniqueConstraint(
|
||||
name: "AK_EFClients_NetworkId_GameName",
|
||||
table: "EFClients");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_EFClients_NetworkId",
|
||||
table: "EFClients");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "GameName",
|
||||
table: "EFClients",
|
||||
type: "INTEGER",
|
||||
nullable: true,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "INTEGER");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFClients_NetworkId",
|
||||
table: "EFClients",
|
||||
column: "NetworkId",
|
||||
unique: true);
|
||||
}
|
||||
}
|
||||
}
|
1637
Data/Migrations/Sqlite/20220616225008_AddDescendingTimeSentIndexEFClientMessages.Designer.cs
generated
Normal file
1637
Data/Migrations/Sqlite/20220616225008_AddDescendingTimeSentIndexEFClientMessages.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,19 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Data.Migrations.Sqlite
|
||||
{
|
||||
public partial class AddDescendingTimeSentIndexEFClientMessages : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -62,6 +62,9 @@ namespace Data.Migrations.Sqlite
|
||||
b.Property<DateTime>("FirstConnection")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("GameName")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("LastConnection")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
@ -85,12 +88,13 @@ namespace Data.Migrations.Sqlite
|
||||
|
||||
b.HasKey("ClientId");
|
||||
|
||||
b.HasAlternateKey("NetworkId", "GameName");
|
||||
|
||||
b.HasIndex("AliasLinkId");
|
||||
|
||||
b.HasIndex("CurrentAliasId");
|
||||
|
||||
b.HasIndex("NetworkId")
|
||||
.IsUnique();
|
||||
b.HasIndex("NetworkId");
|
||||
|
||||
b.ToTable("EFClients", (string)null);
|
||||
});
|
||||
@ -451,6 +455,8 @@ namespace Data.Migrations.Sqlite
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("CreatedDateTime");
|
||||
|
||||
b.HasIndex("Ranking");
|
||||
|
||||
b.HasIndex("ServerId");
|
||||
@ -802,6 +808,11 @@ namespace Data.Migrations.Sqlite
|
||||
.HasMaxLength(24)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("SearchableIPAddress")
|
||||
.ValueGeneratedOnAddOrUpdate()
|
||||
.HasColumnType("TEXT")
|
||||
.HasComputedColumnSql("((IPAddress & 255) || '.' || ((IPAddress >> 8) & 255)) || '.' || ((IPAddress >> 16) & 255) || '.' || ((IPAddress >> 24) & 255)", true);
|
||||
|
||||
b.Property<string>("SearchableName")
|
||||
.HasMaxLength(24)
|
||||
.HasColumnType("TEXT");
|
||||
@ -814,6 +825,8 @@ namespace Data.Migrations.Sqlite
|
||||
|
||||
b.HasIndex("Name");
|
||||
|
||||
b.HasIndex("SearchableIPAddress");
|
||||
|
||||
b.HasIndex("SearchableName");
|
||||
|
||||
b.HasIndex("Name", "IPAddress");
|
||||
@ -1079,6 +1092,9 @@ namespace Data.Migrations.Sqlite
|
||||
b.Property<int>("ClientCount")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool?>("ConnectionInterrupted")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("MapId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
|
@ -63,6 +63,7 @@ namespace Data.Models.Client
|
||||
public DateTime FirstConnection { get; set; }
|
||||
[Required]
|
||||
public DateTime LastConnection { get; set; }
|
||||
public Reference.Game GameName { get; set; } = Reference.Game.UKN;
|
||||
public bool Masked { get; set; }
|
||||
[Required]
|
||||
public int AliasLinkId { get; set; }
|
||||
|
@ -7,8 +7,6 @@ namespace Data.Models.Client.Stats
|
||||
{
|
||||
public class EFClientRankingHistory: AuditFields
|
||||
{
|
||||
public const int MaxRankingCount = 30;
|
||||
|
||||
[Key]
|
||||
public long ClientRankingHistoryId { get; set; }
|
||||
|
||||
|
@ -86,6 +86,7 @@ namespace Data.Models.Configuration
|
||||
entity.HasIndex(ranking => ranking.Ranking);
|
||||
entity.HasIndex(ranking => ranking.ZScore);
|
||||
entity.HasIndex(ranking => ranking.UpdatedDateTime);
|
||||
entity.HasIndex(ranking => ranking.CreatedDateTime);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ namespace Data.Models
|
||||
public string SearchableName { get; set; }
|
||||
[Required]
|
||||
public int? IPAddress { get; set; }
|
||||
public string SearchableIPAddress { get; set; }
|
||||
[Required]
|
||||
public DateTime DateAdded { get; set; }
|
||||
|
||||
|
@ -15,7 +15,8 @@
|
||||
T6 = 7,
|
||||
T7 = 8,
|
||||
SHG1 = 9,
|
||||
CSGO = 10
|
||||
CSGO = 10,
|
||||
H1 = 11
|
||||
}
|
||||
|
||||
public enum ConnectionType
|
||||
|
@ -32,5 +32,7 @@ namespace Data.Models.Server
|
||||
public EFMap Map { get; set; }
|
||||
|
||||
public int ClientCount { get; set; }
|
||||
|
||||
public bool? ConnectionInterrupted {get;set;}
|
||||
}
|
||||
}
|
@ -53,7 +53,9 @@ steps:
|
||||
script: |
|
||||
Write-Host 'Build Configuration is $(buildConfiguration), Release Type is $(releaseType)'
|
||||
md -Force lib\open-iconic\font\css
|
||||
wget https://raw.githubusercontent.com/iconic/open-iconic/master/font/css/open-iconic-bootstrap.scss -o lib\open-iconic\font\css\open-iconic-bootstrap.scss
|
||||
wget https://raw.githubusercontent.com/iconic/open-iconic/master/font/css/open-iconic-bootstrap.scss -o lib\open-iconic\font\css\open-iconic-bootstrap-override.scss
|
||||
cd lib\open-iconic\font\css
|
||||
(Get-Content open-iconic-bootstrap-override.scss).replace('../fonts/', '/font/') | Set-Content open-iconic-bootstrap-override.scss
|
||||
failOnStderr: true
|
||||
workingDirectory: '$(Build.Repository.LocalPath)\WebfrontCore\wwwroot'
|
||||
|
||||
@ -75,6 +77,7 @@ steps:
|
||||
Write-Host 'Unzipping download'
|
||||
Expand-Archive -LiteralPath $(Build.Repository.LocalPath)\dotnet-bundle.zip -DestinationPath $(Build.Repository.LocalPath)
|
||||
Write-Host 'Executing dotnet-bundle'
|
||||
$(Build.Repository.LocalPath)\dotnet-bundle.exe clean $(Build.Repository.LocalPath)\WebfrontCore\bundleconfig.json
|
||||
$(Build.Repository.LocalPath)\dotnet-bundle.exe $(Build.Repository.LocalPath)\WebfrontCore\bundleconfig.json
|
||||
failOnStderr: true
|
||||
workingDirectory: '$(Build.Repository.LocalPath)\WebfrontCore'
|
||||
|
@ -29,8 +29,9 @@ onPlayerConnect( player )
|
||||
for( ;; )
|
||||
{
|
||||
level waittill( "connected", player );
|
||||
player setClientDvar("cl_autorecord", 1);
|
||||
player setClientDvar("cl_demosKeep", 200);
|
||||
player setClientDvars( "cl_autorecord", 1,
|
||||
"cl_demosKeep", 200 );
|
||||
|
||||
player thread waitForFrameThread();
|
||||
player thread waitForAttack();
|
||||
}
|
||||
@ -60,7 +61,7 @@ getHttpString( url )
|
||||
|
||||
runRadarUpdates()
|
||||
{
|
||||
interval = int(getDvar("sv_printradar_updateinterval"));
|
||||
interval = getDvarInt( "sv_printradar_updateinterval", 500 );
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
@ -191,7 +192,7 @@ waitForAdditionalAngles( logString, beforeFrameCount, afterFrameCount )
|
||||
i++;
|
||||
}
|
||||
|
||||
lastAttack = int(getTime()) - int(self.lastAttackTime);
|
||||
lastAttack = getTime() - self.lastAttackTime;
|
||||
isAlive = isAlive(self);
|
||||
|
||||
logPrint(logString + ";" + anglesStr + ";" + isAlive + ";" + lastAttack + "\n" );
|
23
GameFiles/AntiCheat/IW5/storage/iw5/scripts/README.MD
Normal file
23
GameFiles/AntiCheat/IW5/storage/iw5/scripts/README.MD
Normal file
@ -0,0 +1,23 @@
|
||||
# IW5
|
||||
|
||||
This expands IW4M-Admins's Anti-cheat to Plutonium IW5
|
||||
## Installation
|
||||
|
||||
Add ``_customcallbacks.gsc`` into the scripts folder. (%localappdata%\Plutonium\storage\iw5\scripts)
|
||||
|
||||
For more info check out Chase's [how-to guide](https://forum.plutonium.pw/topic/10738/tutorial-loading-custom-gsc-scripts).
|
||||
|
||||
You need to add this to you ``StatsPluginSettings.json`` found in your IW4M-Admin configuration folder.
|
||||
|
||||
```
|
||||
"IW5": {
|
||||
"Recoil": [
|
||||
"iw5_1887_mp.*",
|
||||
"turret_minigun_mp"
|
||||
],
|
||||
"Button": [
|
||||
".*akimbo.*"
|
||||
]
|
||||
}
|
||||
```
|
||||
[Example](https://imgur.com/Ji9AafI)
|
@ -53,7 +53,7 @@ waitForAttack()
|
||||
|
||||
runRadarUpdates()
|
||||
{
|
||||
interval = int(getDvar("sv_printradar_updateinterval"));
|
||||
interval = getDvarInt( "sv_printradar_updateinterval", 500 );
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
@ -183,7 +183,7 @@ waitForAdditionalAngles( logString, beforeFrameCount, afterFrameCount )
|
||||
i++;
|
||||
}
|
||||
|
||||
lastAttack = int(getTime()) - int(self.lastAttackTime);
|
||||
lastAttack = getTime() - self.lastAttackTime;
|
||||
isAlive = isAlive(self);
|
||||
|
||||
logPrint(logString + ";" + anglesStr + ";" + isAlive + ";" + lastAttack + "\n" );
|
@ -24,12 +24,12 @@ Add this to the WeaponNameParserConfigurations List in the StatsPluginSettings.j
|
||||
}
|
||||
```
|
||||
|
||||
Now create the following entry for __EVERY__ T6 server you are using this on in the ServerDetectionTypes list:
|
||||
Now update the `GameDetectionTypes` list with the following, if it does not already exist:
|
||||
|
||||
```
|
||||
"1270014976": [
|
||||
"T6": [
|
||||
"Offset",
|
||||
"Strain",
|
||||
"Snap"
|
||||
"Snap",
|
||||
"Strain"
|
||||
]
|
||||
```
|
@ -60,7 +60,7 @@ waitForAttack()
|
||||
|
||||
runRadarUpdates()
|
||||
{
|
||||
interval = int(getDvar("sv_printradar_updateinterval"));
|
||||
interval = getDvarInt( "sv_printradar_updateinterval" );
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
@ -190,7 +190,7 @@ waitForAdditionalAngles( logString, beforeFrameCount, afterFrameCount )
|
||||
i++;
|
||||
}
|
||||
|
||||
lastAttack = int(getTime()) - int(self.lastAttackTime);
|
||||
lastAttack = getTime() - self.lastAttackTime;
|
||||
isAlive = isAlive(self);
|
||||
|
||||
logPrint(logString + ";" + anglesStr + ";" + isAlive + ";" + lastAttack + "\n" );
|
@ -1,10 +1,16 @@
|
||||
#include common_scripts\utility;
|
||||
#include maps\mp\_utility;
|
||||
#include maps\mp\gametypes\_hud_util;
|
||||
#include maps\mp\gametypes\_playerlogic;
|
||||
|
||||
init()
|
||||
Init()
|
||||
{
|
||||
level thread Setup();
|
||||
}
|
||||
|
||||
Setup()
|
||||
{
|
||||
level endon( "game_ended" );
|
||||
|
||||
// setup default vars
|
||||
level.eventBus = spawnstruct();
|
||||
level.eventBus.inVar = "sv_iw4madmin_in";
|
||||
@ -13,6 +19,13 @@ init()
|
||||
level.eventBus.timeoutKey = "timeout";
|
||||
level.eventBus.timeout = 30;
|
||||
|
||||
level.commonFunctions = spawnstruct();
|
||||
level.commonFunctions.SetDvar = "SetDvarIfUninitialized";
|
||||
|
||||
level.notifyTypes = spawnstruct();
|
||||
level.notifyTypes.gameFunctionsInitialized = "GameFunctionsInitialized";
|
||||
level.notifyTypes.integrationBootstrapInitialized = "IntegrationBootstrapInitialized";
|
||||
|
||||
level.clientDataKey = "clientData";
|
||||
|
||||
level.eventTypes = spawnstruct();
|
||||
@ -23,10 +36,7 @@ init()
|
||||
level.eventTypes.setClientDataCompleted = "SetClientDataCompleted";
|
||||
level.eventTypes.executeCommandRequested = "ExecuteCommandRequested";
|
||||
|
||||
SetDvarIfUninitialized( level.eventBus.inVar, "" );
|
||||
SetDvarIfUninitialized( level.eventBus.outVar, "" );
|
||||
SetDvarIfUninitialized( "sv_iw4madmin_integration_enabled", 1 );
|
||||
SetDvarIfUninitialized( "sv_iw4madmin_integration_debug", 0 );
|
||||
level.iw4madminIntegrationDebug = 0;
|
||||
|
||||
// map the event type to the handler
|
||||
level.eventCallbacks = [];
|
||||
@ -34,6 +44,26 @@ init()
|
||||
level.eventCallbacks[level.eventTypes.executeCommandRequested] = ::OnExecuteCommand;
|
||||
level.eventCallbacks[level.eventTypes.setClientDataCompleted] = ::OnSetClientDataCompleted;
|
||||
|
||||
level.clientCommandCallbacks = [];
|
||||
level.clientCommandRusAsTarget = [];
|
||||
level.logger = spawnstruct();
|
||||
level.overrideMethods = [];
|
||||
|
||||
level.iw4madminIntegrationDebug = GetDvarInt( "sv_iw4madmin_integration_debug" );
|
||||
InitializeLogger();
|
||||
|
||||
wait ( 0.05 ); // needed to give script engine time to propagate notifies
|
||||
|
||||
level notify( level.notifyTypes.integrationBootstrapInitialized );
|
||||
level waittill( level.notifyTypes.gameFunctionsInitialized );
|
||||
|
||||
LogDebug( "Integration received notify that game functions are initialized" );
|
||||
|
||||
_SetDvarIfUninitialized( level.eventBus.inVar, "" );
|
||||
_SetDvarIfUninitialized( level.eventBus.outVar, "" );
|
||||
_SetDvarIfUninitialized( "sv_iw4madmin_integration_enabled", 1 );
|
||||
_SetDvarIfUninitialized( "sv_iw4madmin_integration_debug", 0 );
|
||||
|
||||
if ( GetDvarInt( "sv_iw4madmin_integration_enabled" ) != 1 )
|
||||
{
|
||||
return;
|
||||
@ -51,15 +81,19 @@ init()
|
||||
|
||||
OnPlayerConnect()
|
||||
{
|
||||
level endon ( "disconnect" );
|
||||
level endon ( "game_ended" );
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
level waittill( "connected", player );
|
||||
|
||||
level.iw4adminIntegrationDebug = GetDvarInt( "sv_iw4madmin_integration_debug" );
|
||||
if ( _IsBot( player ) )
|
||||
{
|
||||
// we don't want to track bots
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !isDefined( player.pers[level.clientDataKey] ) )
|
||||
if ( !IsDefined( player.pers[level.clientDataKey] ) )
|
||||
{
|
||||
player.pers[level.clientDataKey] = spawnstruct();
|
||||
}
|
||||
@ -68,12 +102,6 @@ OnPlayerConnect()
|
||||
player thread OnPlayerJoinedTeam();
|
||||
player thread OnPlayerJoinedSpectators();
|
||||
player thread PlayerTrackingOnInterval();
|
||||
|
||||
// only toggle if it's enabled
|
||||
if ( IsDefined( level.nightModeEnabled ) && level.nightModeEnabled )
|
||||
{
|
||||
player ToggleNightMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,13 +112,13 @@ OnPlayerSpawned()
|
||||
for ( ;; )
|
||||
{
|
||||
self waittill( "spawned_player" );
|
||||
self PlayerConnectEvents();
|
||||
self PlayerSpawnEvents();
|
||||
}
|
||||
}
|
||||
|
||||
OnPlayerDisconnect()
|
||||
{
|
||||
level endon ( "disconnect" );
|
||||
self endon ( "disconnect" );
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
@ -125,8 +153,6 @@ OnPlayerJoinedSpectators()
|
||||
|
||||
OnGameEnded()
|
||||
{
|
||||
level endon ( "disconnect" );
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
level waittill( "game_ended" );
|
||||
@ -151,29 +177,22 @@ DisplayWelcomeData()
|
||||
self IPrintLnBold( "You were last seen ^5" + clientData.lastConnection );
|
||||
}
|
||||
|
||||
PlayerConnectEvents()
|
||||
PlayerSpawnEvents()
|
||||
{
|
||||
self endon( "disconnect" );
|
||||
|
||||
if ( IsDefined( self.isHidden ) && self.isHidden )
|
||||
{
|
||||
self HideImpl();
|
||||
}
|
||||
|
||||
clientData = self.pers[level.clientDataKey];
|
||||
|
||||
// this gives IW4MAdmin some time to register the player before making the request;
|
||||
// although probably not necessary some users might have a slow database or poll rate
|
||||
wait ( 2 );
|
||||
|
||||
if ( isDefined( clientData.state ) && clientData.state == "complete" )
|
||||
if ( IsDefined( clientData.state ) && clientData.state == "complete" )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
self RequestClientBasicData();
|
||||
// example of requesting meta from IW4MAdmin
|
||||
// self RequestClientMeta( "LastServerPlayed" );
|
||||
}
|
||||
|
||||
PlayerTrackingOnInterval()
|
||||
@ -192,23 +211,21 @@ PlayerTrackingOnInterval()
|
||||
|
||||
MonitorClientEvents()
|
||||
{
|
||||
level endon( "disconnect" );
|
||||
self endon( "disconnect" );
|
||||
level endon( "game_ended" );
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
level waittill( level.eventTypes.localClientEvent, client );
|
||||
|
||||
if ( level.iw4adminIntegrationDebug == 1 )
|
||||
{
|
||||
self IPrintLn( "Processing Event " + client.event.type + "-" + client.event.subtype );
|
||||
}
|
||||
LogDebug( "Processing Event " + client.event.type + "-" + client.event.subtype );
|
||||
|
||||
eventHandler = level.eventCallbacks[client.event.type];
|
||||
|
||||
if ( isDefined( eventHandler ) )
|
||||
if ( IsDefined( eventHandler ) )
|
||||
{
|
||||
client [[eventHandler]]( client.event );
|
||||
LogDebug( "notify client for " + client.event.type );
|
||||
client notify( level.eventTypes.localClientEvent, client.event );
|
||||
}
|
||||
|
||||
client.eventData = [];
|
||||
@ -219,6 +236,95 @@ MonitorClientEvents()
|
||||
// Helper Methods
|
||||
//////////////////////////////////
|
||||
|
||||
_IsBot( entity )
|
||||
{
|
||||
// there already is a cgame function exists as "IsBot", for IW4, but unsure what all titles have it defined,
|
||||
// so we are defining it here
|
||||
return IsDefined( entity.pers["isBot"] ) && entity.pers["isBot"];
|
||||
}
|
||||
|
||||
_SetDvarIfUninitialized( dvarName, dvarValue )
|
||||
{
|
||||
[[level.overrideMethods[level.commonFunctions.SetDvar]]]( dvarName, dvarValue );
|
||||
}
|
||||
|
||||
// Not every game can output to console or even game log.
|
||||
// Adds a very basic logging system that every
|
||||
// game specific script can extend.accumulate
|
||||
// Logging to dvars used as example.
|
||||
InitializeLogger()
|
||||
{
|
||||
level.logger._logger = [];
|
||||
RegisterLogger( ::Log2Dvar );
|
||||
RegisterLogger( ::Log2IngamePrint );
|
||||
level.logger.debug = ::LogDebug;
|
||||
level.logger.error = ::LogError;
|
||||
level.logger.warning = ::LogWarning;
|
||||
}
|
||||
|
||||
_Log( LogLevel, message )
|
||||
{
|
||||
for( i = 0; i < level.logger._logger.size; i++ )
|
||||
{
|
||||
[[level.logger._logger[i]]]( LogLevel, message );
|
||||
}
|
||||
}
|
||||
|
||||
LogDebug( message )
|
||||
{
|
||||
if ( level.iw4madminIntegrationDebug )
|
||||
{
|
||||
_Log( "debug", level.eventBus.gamename + ": " + message );
|
||||
}
|
||||
}
|
||||
|
||||
LogError( message )
|
||||
{
|
||||
_Log( "error", message );
|
||||
}
|
||||
|
||||
LogWarning( message )
|
||||
{
|
||||
_Log( "warning", message );
|
||||
}
|
||||
|
||||
Log2Dvar( LogLevel, message )
|
||||
{
|
||||
switch ( LogLevel )
|
||||
{
|
||||
case "debug":
|
||||
SetDvar( "sv_iw4madmin_last_debug", message );
|
||||
break;
|
||||
case "error":
|
||||
SetDvar( "sv_iw4madmin_last_error", message );
|
||||
break;
|
||||
case "warning":
|
||||
SetDvar( "sv_iw4madmin_last_warning", message );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Log2IngamePrint( LogLevel, message )
|
||||
{
|
||||
switch ( LogLevel )
|
||||
{
|
||||
case "debug":
|
||||
IPrintLn( "[DEBUG] " + message );
|
||||
break;
|
||||
case "error":
|
||||
IPrintLn( "[ERROR] " + message );
|
||||
break;
|
||||
case "warning":
|
||||
IPrintLn( "[WARN] " + message );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
RegisterLogger( logger )
|
||||
{
|
||||
level.logger._logger[level.logger._logger.size] = logger;
|
||||
}
|
||||
|
||||
RequestClientMeta( metaKey )
|
||||
{
|
||||
getClientMetaEvent = BuildEventRequest( true, level.eventTypes.clientDataRequested, "Meta", self, metaKey );
|
||||
@ -299,24 +405,23 @@ SetClientMeta( metaKey, metaValue, clientId, direction )
|
||||
|
||||
SaveTrackingMetrics()
|
||||
{
|
||||
if ( level.iw4adminIntegrationDebug == 1 )
|
||||
if ( !IsDefined( self.persistentClientId ) )
|
||||
{
|
||||
IPrintLn( "Saving tracking metrics for " + self.persistentClientId );
|
||||
return;
|
||||
}
|
||||
|
||||
LogDebug( "Saving tracking metrics for " + self.persistentClientId );
|
||||
|
||||
if ( !IsDefined( self.lastShotCount ) )
|
||||
{
|
||||
self.lastShotCount = 0;
|
||||
}
|
||||
|
||||
currentShotCount = self getPlayerStat( "mostshotsfired" );
|
||||
currentShotCount = self [[level.overrideMethods["GetTotalShotsFired"]]]();
|
||||
change = currentShotCount - self.lastShotCount;
|
||||
self.lastShotCount = currentShotCount;
|
||||
|
||||
if ( level.iw4adminIntegrationDebug == 1 )
|
||||
{
|
||||
IPrintLn( "Total Shots Fired increased by " + change );
|
||||
}
|
||||
LogDebug( "Total Shots Fired increased by " + change );
|
||||
|
||||
if ( !IsDefined( change ) )
|
||||
{
|
||||
@ -329,17 +434,16 @@ SaveTrackingMetrics()
|
||||
}
|
||||
|
||||
IncrementClientMeta( "TotalShotsFired", change, self.persistentClientId );
|
||||
|
||||
}
|
||||
|
||||
BuildEventRequest( responseExpected, eventType, eventSubtype, entOrId, data )
|
||||
{
|
||||
if ( !isDefined( data ) )
|
||||
if ( !IsDefined( data ) )
|
||||
{
|
||||
data = "";
|
||||
}
|
||||
|
||||
if ( !isDefined( eventSubtype ) )
|
||||
if ( !IsDefined( eventSubtype ) )
|
||||
{
|
||||
eventSubtype = "None";
|
||||
}
|
||||
@ -380,10 +484,7 @@ MonitorBus()
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ( level.iw4adminIntegrationDebug == 1 )
|
||||
{
|
||||
IPrintLn( "-> " + eventString );
|
||||
}
|
||||
LogDebug( "-> " + eventString );
|
||||
|
||||
NotifyClientEvent( strtok( eventString, ";" ) );
|
||||
|
||||
@ -393,7 +494,7 @@ MonitorBus()
|
||||
|
||||
QueueEvent( request, eventType, notifyEntity )
|
||||
{
|
||||
level endon( "disconnect" );
|
||||
level endon( "game_ended" );
|
||||
|
||||
start = GetTime();
|
||||
maxWait = level.eventBus.timeout * 1000; // 30 seconds
|
||||
@ -401,14 +502,11 @@ QueueEvent( request, eventType, notifyEntity )
|
||||
|
||||
while ( GetDvar( level.eventBus.inVar ) != "" && ( GetTime() - start ) < maxWait )
|
||||
{
|
||||
level waittill_notify_or_timeout( "bus_ready", 1 );
|
||||
level [[level.overrideMethods["waittill_notify_or_timeout"]]]( "bus_ready", 1 );
|
||||
|
||||
if ( GetDvar( level.eventBus.inVar ) != "" )
|
||||
{
|
||||
if ( level.iw4adminIntegrationDebug == 1 )
|
||||
{
|
||||
IPrintLn( "A request is already in progress..." );
|
||||
}
|
||||
LogDebug( "A request is already in progress..." );
|
||||
timedOut = "set";
|
||||
continue;
|
||||
}
|
||||
@ -418,41 +516,42 @@ QueueEvent( request, eventType, notifyEntity )
|
||||
|
||||
if ( timedOut == "set")
|
||||
{
|
||||
if ( level.iw4adminIntegrationDebug == 1 )
|
||||
{
|
||||
IPrintLn( "Timed out waiting for response..." );
|
||||
}
|
||||
LogDebug( "Timed out waiting for response..." );
|
||||
|
||||
if ( IsDefined( notifyEntity ) )
|
||||
{
|
||||
notifyEntity NotifyClientEventTimeout( eventType );
|
||||
}
|
||||
|
||||
SetDvar( level.eventBus.inVar, "" );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( level.iw4adminIntegrationDebug == 1 )
|
||||
{
|
||||
IPrintLn("<- " + request);
|
||||
}
|
||||
LogDebug("<- " + request );
|
||||
|
||||
SetDvar( level.eventBus.inVar, request );
|
||||
}
|
||||
|
||||
ParseDataString( data )
|
||||
{
|
||||
if ( !IsDefined( data ) )
|
||||
{
|
||||
LogDebug( "No data to parse" );
|
||||
return [];
|
||||
}
|
||||
|
||||
dataParts = strtok( data, "|" );
|
||||
dict = [];
|
||||
|
||||
counter = 0;
|
||||
foreach ( part in dataParts )
|
||||
for ( i = 0; i < dataParts.size; i++ )
|
||||
{
|
||||
part = dataParts[i];
|
||||
splitPart = strtok( part, "=" );
|
||||
key = splitPart[0];
|
||||
value = splitPart[1];
|
||||
dict[key] = value;
|
||||
dict[counter] = key;
|
||||
counter++;
|
||||
dict[i] = key;
|
||||
}
|
||||
|
||||
return dict;
|
||||
@ -479,17 +578,68 @@ NotifyClientEvent( eventInfo )
|
||||
event.origin = origin;
|
||||
event.target = target;
|
||||
|
||||
if ( level.iw4adminIntegrationDebug == 1 )
|
||||
if ( IsDefined( event.data ) )
|
||||
{
|
||||
IPrintLn( "NotifyClientEvent->" + event.data );
|
||||
LogDebug( "NotifyClientEvent->" + event.data );
|
||||
}
|
||||
|
||||
client = event.origin;
|
||||
client.event = event;
|
||||
if ( int( eventInfo[3] ) != -1 && !IsDefined( origin ) )
|
||||
{
|
||||
LogDebug( "origin is null but the slot id is " + int( eventInfo[3] ) );
|
||||
}
|
||||
if ( int( eventInfo[4] ) != -1 && !IsDefined( target ) )
|
||||
{
|
||||
LogDebug( "target is null but the slot id is " + int( eventInfo[4] ) );
|
||||
}
|
||||
|
||||
if ( IsDefined( target ) )
|
||||
{
|
||||
client = event.target;
|
||||
}
|
||||
else if ( IsDefined( origin ) )
|
||||
{
|
||||
client = event.origin;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogDebug( "Neither origin or target are set but we are a Client Event, aborting" );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
client.event = event;
|
||||
level notify( level.eventTypes.localClientEvent, client );
|
||||
}
|
||||
|
||||
GetPlayerFromClientNum( clientNum )
|
||||
{
|
||||
if ( clientNum < 0 )
|
||||
{
|
||||
return undefined;
|
||||
}
|
||||
|
||||
for ( i = 0; i < level.players.size; i++ )
|
||||
{
|
||||
if ( level.players[i] getEntityNumber() == clientNum )
|
||||
{
|
||||
return level.players[i];
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
AddClientCommand( commandName, shouldRunAsTarget, callback, shouldOverwrite )
|
||||
{
|
||||
if ( IsDefined( level.clientCommandCallbacks[commandName] ) && IsDefined( shouldOverwrite ) && !shouldOverwrite )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
level.clientCommandCallbacks[commandName] = callback;
|
||||
level.clientCommandRusAsTarget[commandName] = shouldRunAsTarget == true; //might speed up things later in case someone gives us a string or number instead of a boolean
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
// Event Handlers
|
||||
/////////////////////////////////
|
||||
@ -501,17 +651,14 @@ OnClientDataReceived( event )
|
||||
|
||||
if ( event.subtype == "Fail" )
|
||||
{
|
||||
if ( level.iw4adminIntegrationDebug == 1 )
|
||||
{
|
||||
IPrintLn( "Received fail response" );
|
||||
}
|
||||
LogDebug( "Received fail response" );
|
||||
clientData.state = level.eventBus.failKey;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( event.subtype == "Meta" )
|
||||
{
|
||||
if ( !isDefined( clientData.meta ) )
|
||||
if ( !IsDefined( clientData.meta ) )
|
||||
{
|
||||
clientData.meta = [];
|
||||
}
|
||||
@ -519,12 +666,15 @@ OnClientDataReceived( event )
|
||||
metaKey = event.data[0];
|
||||
clientData.meta[metaKey] = event.data[metaKey];
|
||||
|
||||
LogDebug( "Meta Key=" + metaKey + ", Meta Value=" + event.data[metaKey] );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
clientData.permissionLevel = event.data["level"];
|
||||
clientData.clientId = event.data["clientId"];
|
||||
clientData.lastConnection = event.data["lastConnection"];
|
||||
clientData.tag = event.data["tag"];
|
||||
clientData.state = "complete";
|
||||
self.persistentClientId = event.data["clientId"];
|
||||
|
||||
@ -536,49 +686,26 @@ OnExecuteCommand( event )
|
||||
data = ParseDataString( event.data );
|
||||
response = "";
|
||||
|
||||
switch ( event.subtype )
|
||||
command = level.clientCommandCallbacks[event.subtype];
|
||||
runAsTarget = level.clientCommandRusAsTarget[event.subtype];
|
||||
executionContextEntity = event.origin;
|
||||
|
||||
if ( runAsTarget )
|
||||
{
|
||||
case "GiveWeapon":
|
||||
response = event.target GiveWeaponImpl( data );
|
||||
break;
|
||||
case "TakeWeapons":
|
||||
response = event.target TakeWeaponsImpl();
|
||||
break;
|
||||
case "SwitchTeams":
|
||||
response = event.target TeamSwitchImpl();
|
||||
break;
|
||||
case "Hide":
|
||||
response = self HideImpl();
|
||||
break;
|
||||
case "Unhide":
|
||||
response = self UnhideImpl();
|
||||
break;
|
||||
case "Alert":
|
||||
response = event.target AlertImpl( data );
|
||||
break;
|
||||
case "Goto":
|
||||
if ( IsDefined( event.target ) )
|
||||
executionContextEntity = event.target;
|
||||
}
|
||||
|
||||
if ( IsDefined( command ) )
|
||||
{
|
||||
response = self GotoPlayerImpl( event.target );
|
||||
response = executionContextEntity [[command]]( event, data );
|
||||
}
|
||||
else
|
||||
{
|
||||
response = self GotoImpl( data );
|
||||
}
|
||||
break;
|
||||
case "Kill":
|
||||
response = event.target KillImpl();
|
||||
break;
|
||||
case "NightMode":
|
||||
NightModeImpl();
|
||||
break;
|
||||
case "SetSpectator":
|
||||
response = event.target SetSpectatorImpl();
|
||||
break;
|
||||
LogDebug( "Unknown Client command->" + event.subtype );
|
||||
}
|
||||
|
||||
// send back the response to the origin, but only if they're not the target
|
||||
if ( response != "" && IsPlayer( event.origin ) && event.origin != event.target )
|
||||
if ( IsDefined( response ) && response != "" && IsPlayer( event.origin ) && event.origin != event.target )
|
||||
{
|
||||
event.origin IPrintLnBold( response );
|
||||
}
|
||||
@ -587,213 +714,5 @@ OnExecuteCommand( event )
|
||||
OnSetClientDataCompleted( event )
|
||||
{
|
||||
// IW4MAdmin let us know it persisted (success or fail)
|
||||
if ( level.iw4adminIntegrationDebug == 1 )
|
||||
{
|
||||
IPrintLn( "Set Client Data -> subtype = " + event.subType + " status = " + event.data["status"] );
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
// Command Implementations
|
||||
/////////////////////////////////
|
||||
|
||||
GiveWeaponImpl( data )
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
return self.name + "^7 is not alive";
|
||||
}
|
||||
|
||||
self IPrintLnBold( "You have been given a new weapon" );
|
||||
self GiveWeapon( data["weaponName"] );
|
||||
self SwitchToWeapon( data["weaponName"] );
|
||||
|
||||
return self.name + "^7 has been given ^5" + data["weaponName"];
|
||||
}
|
||||
|
||||
TakeWeaponsImpl()
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
return self.name + "^7 is not alive";
|
||||
}
|
||||
|
||||
self TakeAllWeapons();
|
||||
self IPrintLnBold( "All your weapons have been taken" );
|
||||
|
||||
return "Took weapons from " + self.name;
|
||||
}
|
||||
|
||||
TeamSwitchImpl()
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
return self.name + "^7 is not alive";
|
||||
}
|
||||
|
||||
team = level.allies;
|
||||
|
||||
if ( self.team == "allies" )
|
||||
{
|
||||
team = level.axis;
|
||||
}
|
||||
|
||||
self IPrintLnBold( "You are being team switched" );
|
||||
wait( 2 );
|
||||
self [[team]]();
|
||||
|
||||
return self.name + "^7 switched to " + self.team;
|
||||
}
|
||||
|
||||
HideImpl()
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
self IPrintLnBold( "You are not alive" );
|
||||
return;
|
||||
}
|
||||
|
||||
self SetClientDvar( "sv_cheats", 1 );
|
||||
self SetClientDvar( "cg_thirdperson", 1 );
|
||||
self SetClientDvar( "sv_cheats", 0 );
|
||||
|
||||
if ( !IsDefined( self.savedHealth ) || self.health < 1000 )
|
||||
{
|
||||
self.savedHealth = self.health;
|
||||
self.savedMaxHealth = self.maxhealth;
|
||||
}
|
||||
|
||||
self.maxhealth = 99999;
|
||||
self.health = 99999;
|
||||
self.isHidden = true;
|
||||
|
||||
self Hide();
|
||||
|
||||
self IPrintLnBold( "You are now ^5hidden ^7from other players" );
|
||||
}
|
||||
|
||||
UnhideImpl()
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
self IPrintLnBold( "You are not alive" );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !IsDefined( self.isHidden ) || !self.isHidden )
|
||||
{
|
||||
self IPrintLnBold( "You are not hidden" );
|
||||
return;
|
||||
}
|
||||
|
||||
self SetClientDvar( "sv_cheats", 1 );
|
||||
self SetClientDvar( "cg_thirdperson", 0 );
|
||||
self SetClientDvar( "sv_cheats", 0 );
|
||||
|
||||
self.health = self.savedHealth;
|
||||
self.maxhealth = self.savedMaxHealth;
|
||||
self.isHidden = false;
|
||||
|
||||
self Show();
|
||||
self IPrintLnBold( "You are now ^5visible ^7to other players" );
|
||||
}
|
||||
|
||||
AlertImpl( data )
|
||||
{
|
||||
self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( data["alertType"], data["message"], "compass_waypoint_target", ( 1, 0, 0 ), "ui_mp_nukebomb_timer", 7.5 );
|
||||
return "Sent alert to " + self.name;
|
||||
}
|
||||
|
||||
GotoImpl( data )
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
self IPrintLnBold( "You are not alive" );
|
||||
return;
|
||||
}
|
||||
|
||||
position = ( int(data["x"]), int(data["y"]), int(data["z"]) );
|
||||
self SetOrigin( position );
|
||||
self IPrintLnBold( "Moved to " + "("+ position[0] + "," + position[1] + "," + position[2] + ")" );
|
||||
}
|
||||
|
||||
GotoPlayerImpl( target )
|
||||
{
|
||||
if ( !IsAlive( target ) )
|
||||
{
|
||||
self IPrintLnBold( target.name + " is not alive" );
|
||||
return;
|
||||
}
|
||||
|
||||
self SetOrigin( target GetOrigin() );
|
||||
self IPrintLnBold( "Moved to " + target.name );
|
||||
}
|
||||
|
||||
KillImpl()
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
return self.name + " is not alive";
|
||||
}
|
||||
|
||||
self Suicide();
|
||||
self IPrintLnBold( "You were killed by " + self.name );
|
||||
|
||||
return "You killed " + self.name;
|
||||
}
|
||||
|
||||
NightModeImpl()
|
||||
{
|
||||
if ( !IsDefined ( level.nightModeEnabled ) )
|
||||
{
|
||||
level.nightModeEnabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
level.nightModeEnabled = !level.nightModeEnabled;
|
||||
}
|
||||
|
||||
message = "^5NightMode ^7is disabled";
|
||||
|
||||
if ( level.nightModeEnabled )
|
||||
{
|
||||
message = "^5NightMode ^7is enabled";
|
||||
}
|
||||
|
||||
IPrintLnBold( message );
|
||||
|
||||
foreach( player in level.players )
|
||||
{
|
||||
player ToggleNightMode();
|
||||
}
|
||||
}
|
||||
|
||||
ToggleNightMode()
|
||||
{
|
||||
colorMap = 1;
|
||||
fxDraw = 1;
|
||||
|
||||
if ( IsDefined( level.nightModeEnabled ) && level.nightModeEnabled )
|
||||
{
|
||||
colorMap = 0;
|
||||
fxDraw = 0;
|
||||
}
|
||||
|
||||
self SetClientDvar( "sv_cheats", 1 );
|
||||
self SetClientDvar( "r_colorMap", colorMap );
|
||||
self SetClientDvar( "fx_draw", fxDraw );
|
||||
self SetClientDvar( "sv_cheats", 0 );
|
||||
}
|
||||
|
||||
SetSpectatorImpl()
|
||||
{
|
||||
if ( self.pers["team"] == "spectator" )
|
||||
{
|
||||
return self.name + " is already spectating";
|
||||
}
|
||||
|
||||
self [[level.spectator]]();
|
||||
self IPrintLnBold( "You have been moved to spectator" );
|
||||
|
||||
return self.name + " has been moved to spectator";
|
||||
LogDebug( "Set Client Data -> subtype = " + event.subType + " status = " + event.data["status"] );
|
||||
}
|
500
GameFiles/GameInterface/_integration_iw4x.gsc
Normal file
500
GameFiles/GameInterface/_integration_iw4x.gsc
Normal file
@ -0,0 +1,500 @@
|
||||
#include common_scripts\iw4x_utility;
|
||||
|
||||
Init()
|
||||
{
|
||||
level.eventBus.gamename = "IW4";
|
||||
|
||||
level thread Setup();
|
||||
}
|
||||
|
||||
Setup()
|
||||
{
|
||||
level endon( "game_ended" );
|
||||
|
||||
// it's possible that the notify type has not been defined yet so we have to hard code it
|
||||
level waittill( "IntegrationBootstrapInitialized" );
|
||||
|
||||
scripts\_integration_base::RegisterLogger( ::Log2Console );
|
||||
|
||||
level.overrideMethods["GetTotalShotsFired"] = ::GetTotalShotsFired;
|
||||
level.overrideMethods["SetDvarIfUninitialized"] = ::_SetDvarIfUninitialized;
|
||||
level.overrideMethods["waittill_notify_or_timeout"] = ::_waittill_notify_or_timeout;
|
||||
|
||||
RegisterClientCommands();
|
||||
|
||||
level notify( level.notifyTypes.gameFunctionsInitialized );
|
||||
|
||||
if ( GetDvarInt( "sv_iw4madmin_integration_enabled" ) != 1 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
level thread OnPlayerConnect();
|
||||
}
|
||||
|
||||
OnPlayerConnect()
|
||||
{
|
||||
level endon ( "game_ended" );
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
level waittill( "connected", player );
|
||||
|
||||
if ( scripts\_integration_base::_IsBot( player ) )
|
||||
{
|
||||
// we don't want to track bots
|
||||
continue;
|
||||
}
|
||||
|
||||
player thread SetPersistentData();
|
||||
player thread WaitForClientEvents();
|
||||
}
|
||||
}
|
||||
|
||||
RegisterClientCommands()
|
||||
{
|
||||
scripts\_integration_base::AddClientCommand( "GiveWeapon", true, ::GiveWeaponImpl );
|
||||
scripts\_integration_base::AddClientCommand( "TakeWeapons", true, ::TakeWeaponsImpl );
|
||||
scripts\_integration_base::AddClientCommand( "SwitchTeams", true, ::TeamSwitchImpl );
|
||||
scripts\_integration_base::AddClientCommand( "Hide", false, ::HideImpl );
|
||||
scripts\_integration_base::AddClientCommand( "Alert", true, ::AlertImpl );
|
||||
scripts\_integration_base::AddClientCommand( "Goto", false, ::GotoImpl );
|
||||
scripts\_integration_base::AddClientCommand( "Kill", true, ::KillImpl );
|
||||
scripts\_integration_base::AddClientCommand( "SetSpectator", true, ::SetSpectatorImpl );
|
||||
scripts\_integration_base::AddClientCommand( "LockControls", true, ::LockControlsImpl );
|
||||
scripts\_integration_base::AddClientCommand( "PlayerToMe", true, ::PlayerToMeImpl );
|
||||
scripts\_integration_base::AddClientCommand( "NoClip", false, ::NoClipImpl );
|
||||
}
|
||||
|
||||
WaitForClientEvents()
|
||||
{
|
||||
self endon( "disconnect" );
|
||||
|
||||
// example of requesting a meta value
|
||||
lastServerMetaKey = "LastServerPlayed";
|
||||
// self scripts\_integration_base::RequestClientMeta( lastServerMetaKey );
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
self waittill( level.eventTypes.localClientEvent, event );
|
||||
|
||||
scripts\_integration_base::LogDebug( "Received client event " + event.type );
|
||||
|
||||
if ( event.type == level.eventTypes.clientDataReceived && event.data[0] == lastServerMetaKey )
|
||||
{
|
||||
clientData = self.pers[level.clientDataKey];
|
||||
lastServerPlayed = clientData.meta[lastServerMetaKey];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GetTotalShotsFired()
|
||||
{
|
||||
return maps\mp\_utility::getPlayerStat( "mostshotsfired" );
|
||||
}
|
||||
|
||||
_SetDvarIfUninitialized( dvar, value )
|
||||
{
|
||||
SetDvarIfUninitialized( dvar, value );
|
||||
}
|
||||
|
||||
_waittill_notify_or_timeout( _notify, timeout )
|
||||
{
|
||||
common_scripts\utility::waittill_notify_or_timeout( _notify, timeout );
|
||||
}
|
||||
|
||||
Log2Console( logLevel, message )
|
||||
{
|
||||
PrintConsole( "[" + logLevel + "] " + message + "\n" );
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
// GUID helpers
|
||||
/////////////////////////////////
|
||||
|
||||
SetPersistentData()
|
||||
{
|
||||
self endon( "disconnect" );
|
||||
|
||||
guidHigh = self GetPlayerData( "bests", "none" );
|
||||
guidLow = self GetPlayerData( "awards", "none" );
|
||||
persistentGuid = guidHigh + "," + guidLow;
|
||||
guidIsStored = guidHigh != 0 && guidLow != 0;
|
||||
|
||||
if ( guidIsStored )
|
||||
{
|
||||
// give IW4MAdmin time to collect IP
|
||||
wait( 15 );
|
||||
scripts\_integration_base::LogDebug( "Uploading persistent guid " + persistentGuid );
|
||||
scripts\_integration_base::SetClientMeta( "PersistentClientGuid", persistentGuid );
|
||||
return;
|
||||
}
|
||||
|
||||
guid = self SplitGuid();
|
||||
|
||||
scripts\_integration_base::LogDebug( "Persisting client guid " + guidHigh + "," + guidLow );
|
||||
|
||||
self SetPlayerData( "bests", "none", guid["high"] );
|
||||
self SetPlayerData( "awards", "none", guid["low"] );
|
||||
}
|
||||
|
||||
SplitGuid()
|
||||
{
|
||||
guid = self GetGuid();
|
||||
|
||||
if ( isDefined( self.guid ) )
|
||||
{
|
||||
guid = self.guid;
|
||||
}
|
||||
|
||||
firstPart = 0;
|
||||
secondPart = 0;
|
||||
stringLength = 17;
|
||||
firstPartExp = 0;
|
||||
secondPartExp = 0;
|
||||
|
||||
for ( i = stringLength - 1; i > 0; i-- )
|
||||
{
|
||||
char = GetSubStr( guid, i - 1, i );
|
||||
if ( char == "" )
|
||||
{
|
||||
char = "0";
|
||||
}
|
||||
|
||||
if ( i > stringLength / 2 )
|
||||
{
|
||||
value = GetIntForHexChar( char );
|
||||
power = Pow( 16, secondPartExp );
|
||||
secondPart = secondPart + ( value * power );
|
||||
secondPartExp++;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = GetIntForHexChar( char );
|
||||
power = Pow( 16, firstPartExp );
|
||||
firstPart = firstPart + ( value * power );
|
||||
firstPartExp++;
|
||||
}
|
||||
}
|
||||
|
||||
split = [];
|
||||
split["low"] = int( secondPart );
|
||||
split["high"] = int( firstPart );
|
||||
|
||||
return split;
|
||||
}
|
||||
|
||||
Pow( num, exponent )
|
||||
{
|
||||
result = 1;
|
||||
while( exponent != 0 )
|
||||
{
|
||||
result = result * num;
|
||||
exponent--;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
GetIntForHexChar( char )
|
||||
{
|
||||
char = ToLower( char );
|
||||
// generated by co-pilot because I can't be bothered to make it more "elegant"
|
||||
switch( char )
|
||||
{
|
||||
case "0":
|
||||
return 0;
|
||||
case "1":
|
||||
return 1;
|
||||
case "2":
|
||||
return 2;
|
||||
case "3":
|
||||
return 3;
|
||||
case "4":
|
||||
return 4;
|
||||
case "5":
|
||||
return 5;
|
||||
case "6":
|
||||
return 6;
|
||||
case "7":
|
||||
return 7;
|
||||
case "8":
|
||||
return 8;
|
||||
case "9":
|
||||
return 9;
|
||||
case "a":
|
||||
return 10;
|
||||
case "b":
|
||||
return 11;
|
||||
case "c":
|
||||
return 12;
|
||||
case "d":
|
||||
return 13;
|
||||
case "e":
|
||||
return 14;
|
||||
case "f":
|
||||
return 15;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
// Command Implementations
|
||||
/////////////////////////////////
|
||||
|
||||
GiveWeaponImpl( event, data )
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
return self.name + "^7 is not alive";
|
||||
}
|
||||
|
||||
self IPrintLnBold( "You have been given a new weapon" );
|
||||
self GiveWeapon( data["weaponName"] );
|
||||
self SwitchToWeapon( data["weaponName"] );
|
||||
|
||||
return self.name + "^7 has been given ^5" + data["weaponName"];
|
||||
}
|
||||
|
||||
TakeWeaponsImpl()
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
return self.name + "^7 is not alive";
|
||||
}
|
||||
|
||||
self TakeAllWeapons();
|
||||
self IPrintLnBold( "All your weapons have been taken" );
|
||||
|
||||
return "Took weapons from " + self.name;
|
||||
}
|
||||
|
||||
TeamSwitchImpl()
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
return self + "^7 is not alive";
|
||||
}
|
||||
|
||||
team = level.allies;
|
||||
|
||||
if ( self.team == "allies" )
|
||||
{
|
||||
team = level.axis;
|
||||
}
|
||||
|
||||
self IPrintLnBold( "You are being team switched" );
|
||||
wait( 2 );
|
||||
self [[team]]();
|
||||
|
||||
return self.name + "^7 switched to " + self.team;
|
||||
}
|
||||
|
||||
LockControlsImpl()
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
return self.name + "^7 is not alive";
|
||||
}
|
||||
|
||||
if ( !IsDefined ( self.isControlLocked ) )
|
||||
{
|
||||
self.isControlLocked = false;
|
||||
}
|
||||
|
||||
if ( !self.isControlLocked )
|
||||
{
|
||||
self freezeControls( true );
|
||||
self God();
|
||||
self Hide();
|
||||
|
||||
info = [];
|
||||
info[ "alertType" ] = "Alert!";
|
||||
info[ "message" ] = "You have been frozen!";
|
||||
|
||||
self AlertImpl( undefined, info );
|
||||
|
||||
self.isControlLocked = true;
|
||||
|
||||
return self.name + "\'s controls are locked";
|
||||
}
|
||||
else
|
||||
{
|
||||
self freezeControls( false );
|
||||
self God();
|
||||
self Show();
|
||||
|
||||
self.isControlLocked = false;
|
||||
|
||||
return self.name + "\'s controls are unlocked";
|
||||
}
|
||||
}
|
||||
|
||||
NoClipImpl()
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
self IPrintLnBold( "You are not alive" );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !IsDefined ( self.isNoClipped ) )
|
||||
{
|
||||
self.isNoClipped = false;
|
||||
}
|
||||
|
||||
if ( !self.isNoClipped )
|
||||
{
|
||||
self SetClientDvar( "sv_cheats", 1 );
|
||||
self SetClientDvar( "cg_thirdperson", 1 );
|
||||
self SetClientDvar( "sv_cheats", 0 );
|
||||
|
||||
self God();
|
||||
self Noclip();
|
||||
self Hide();
|
||||
|
||||
self.isNoClipped = true;
|
||||
|
||||
self IPrintLnBold( "NoClip enabled" );
|
||||
}
|
||||
else
|
||||
{
|
||||
self SetClientDvar( "sv_cheats", 1 );
|
||||
self SetClientDvar( "cg_thirdperson", 0 );
|
||||
self SetClientDvar( "sv_cheats", 0 );
|
||||
|
||||
self God();
|
||||
self Noclip();
|
||||
self Show();
|
||||
|
||||
self.isNoClipped = false;
|
||||
|
||||
self IPrintLnBold( "NoClip disabled" );
|
||||
}
|
||||
}
|
||||
|
||||
HideImpl()
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
self IPrintLnBold( "You are not alive" );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !IsDefined ( self.isHidden ) )
|
||||
{
|
||||
self.isHidden = false;
|
||||
}
|
||||
|
||||
if ( !self.isHidden )
|
||||
{
|
||||
self SetClientDvar( "sv_cheats", 1 );
|
||||
self SetClientDvar( "cg_thirdperson", 1 );
|
||||
self SetClientDvar( "sv_cheats", 0 );
|
||||
|
||||
self God();
|
||||
self Hide();
|
||||
|
||||
self.isHidden = true;
|
||||
|
||||
self IPrintLnBold( "Hide enabled" );
|
||||
}
|
||||
else
|
||||
{
|
||||
self SetClientDvar( "sv_cheats", 1 );
|
||||
self SetClientDvar( "cg_thirdperson", 0 );
|
||||
self SetClientDvar( "sv_cheats", 0 );
|
||||
|
||||
self God();
|
||||
self Show();
|
||||
|
||||
self.isHidden = false;
|
||||
|
||||
self IPrintLnBold( "Hide disabled" );
|
||||
}
|
||||
}
|
||||
|
||||
AlertImpl( event, data )
|
||||
{
|
||||
if ( level.eventBus.gamename == "IW4" )
|
||||
{
|
||||
self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( data["alertType"], data["message"], "compass_waypoint_target", ( 1, 0, 0 ), "ui_mp_nukebomb_timer", 7.5 );
|
||||
}
|
||||
|
||||
return "Sent alert to " + self.name;
|
||||
}
|
||||
|
||||
GotoImpl( event, data )
|
||||
{
|
||||
if ( IsDefined( event.target ) )
|
||||
{
|
||||
return self GotoPlayerImpl( event.target );
|
||||
}
|
||||
else
|
||||
{
|
||||
return self GotoCoordImpl( data );
|
||||
}
|
||||
}
|
||||
|
||||
GotoCoordImpl( data )
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
self IPrintLnBold( "You are not alive" );
|
||||
return;
|
||||
}
|
||||
|
||||
position = ( int( data["x"] ), int( data["y"] ), int( data["z"]) );
|
||||
self SetOrigin( position );
|
||||
self IPrintLnBold( "Moved to " + "("+ position[0] + "," + position[1] + "," + position[2] + ")" );
|
||||
}
|
||||
|
||||
GotoPlayerImpl( target )
|
||||
{
|
||||
if ( !IsAlive( target ) )
|
||||
{
|
||||
self IPrintLnBold( target.name + " is not alive" );
|
||||
return;
|
||||
}
|
||||
|
||||
self SetOrigin( target GetOrigin() );
|
||||
self IPrintLnBold( "Moved to " + target.name );
|
||||
}
|
||||
|
||||
PlayerToMeImpl( event )
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
return self.name + " is not alive";
|
||||
}
|
||||
|
||||
self SetOrigin( event.origin GetOrigin() );
|
||||
return "Moved here " + self.name;
|
||||
}
|
||||
|
||||
KillImpl()
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
return self.name + " is not alive";
|
||||
}
|
||||
|
||||
self Suicide();
|
||||
self IPrintLnBold( "You were killed by " + self.name );
|
||||
|
||||
return "You killed " + self.name;
|
||||
}
|
||||
|
||||
SetSpectatorImpl()
|
||||
{
|
||||
if ( self.pers["team"] == "spectator" )
|
||||
{
|
||||
return self.name + " is already spectating";
|
||||
}
|
||||
|
||||
self [[level.spectator]]();
|
||||
self IPrintLnBold( "You have been moved to spectator" );
|
||||
|
||||
return self.name + " has been moved to spectator";
|
||||
}
|
501
GameFiles/GameInterface/_integration_iw5.gsc
Normal file
501
GameFiles/GameInterface/_integration_iw5.gsc
Normal file
@ -0,0 +1,501 @@
|
||||
#include common_scripts\utility;
|
||||
|
||||
Init()
|
||||
{
|
||||
level.eventBus.gamename = "IW5";
|
||||
|
||||
level thread Setup();
|
||||
}
|
||||
|
||||
Setup()
|
||||
{
|
||||
level endon( "game_ended" );
|
||||
|
||||
// it's possible that the notify type has not been defined yet so we have to hard code it
|
||||
level waittill( "IntegrationBootstrapInitialized" );
|
||||
|
||||
scripts\mp\_integration_base::RegisterLogger( ::Log2Console );
|
||||
|
||||
level.overrideMethods["GetTotalShotsFired"] = ::GetTotalShotsFired;
|
||||
level.overrideMethods["SetDvarIfUninitialized"] = ::_SetDvarIfUninitialized;
|
||||
level.overrideMethods["waittill_notify_or_timeout"] = ::_waittill_notify_or_timeout;
|
||||
|
||||
RegisterClientCommands();
|
||||
|
||||
level notify( level.notifyTypes.gameFunctionsInitialized );
|
||||
|
||||
if ( GetDvarInt( "sv_iw4madmin_integration_enabled" ) != 1 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
level thread OnPlayerConnect();
|
||||
}
|
||||
|
||||
OnPlayerConnect()
|
||||
{
|
||||
level endon ( "game_ended" );
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
level waittill( "connected", player );
|
||||
|
||||
if ( scripts\mp\_integration_base::_IsBot( player ) )
|
||||
{
|
||||
// we don't want to track bots
|
||||
continue;
|
||||
}
|
||||
|
||||
player thread SetPersistentData();
|
||||
player thread WaitForClientEvents();
|
||||
}
|
||||
}
|
||||
|
||||
RegisterClientCommands()
|
||||
{
|
||||
scripts\mp\_integration_base::AddClientCommand( "GiveWeapon", true, ::GiveWeaponImpl );
|
||||
scripts\mp\_integration_base::AddClientCommand( "TakeWeapons", true, ::TakeWeaponsImpl );
|
||||
scripts\mp\_integration_base::AddClientCommand( "SwitchTeams", true, ::TeamSwitchImpl );
|
||||
scripts\mp\_integration_base::AddClientCommand( "Hide", false, ::HideImpl );
|
||||
scripts\mp\_integration_base::AddClientCommand( "Alert", true, ::AlertImpl );
|
||||
scripts\mp\_integration_base::AddClientCommand( "Goto", false, ::GotoImpl );
|
||||
scripts\mp\_integration_base::AddClientCommand( "Kill", true, ::KillImpl );
|
||||
scripts\mp\_integration_base::AddClientCommand( "SetSpectator", true, ::SetSpectatorImpl );
|
||||
scripts\mp\_integration_base::AddClientCommand( "LockControls", true, ::LockControlsImpl );
|
||||
scripts\mp\_integration_base::AddClientCommand( "PlayerToMe", true, ::PlayerToMeImpl );
|
||||
scripts\mp\_integration_base::AddClientCommand( "NoClip", false, ::NoClipImpl );
|
||||
}
|
||||
|
||||
WaitForClientEvents()
|
||||
{
|
||||
self endon( "disconnect" );
|
||||
|
||||
// example of requesting a meta value
|
||||
lastServerMetaKey = "LastServerPlayed";
|
||||
// self scripts\mp\_integration_base::RequestClientMeta( lastServerMetaKey );
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
self waittill( level.eventTypes.localClientEvent, event );
|
||||
|
||||
scripts\mp\_integration_base::LogDebug( "Received client event " + event.type );
|
||||
|
||||
if ( event.type == level.eventTypes.clientDataReceived && event.data[0] == lastServerMetaKey )
|
||||
{
|
||||
clientData = self.pers[level.clientDataKey];
|
||||
lastServerPlayed = clientData.meta[lastServerMetaKey];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GetTotalShotsFired()
|
||||
{
|
||||
return maps\mp\_utility::getPlayerStat( "mostshotsfired" );
|
||||
}
|
||||
|
||||
_SetDvarIfUninitialized( dvar, value )
|
||||
{
|
||||
SetDvarIfUninitialized( dvar, value );
|
||||
}
|
||||
|
||||
_waittill_notify_or_timeout( _notify, timeout )
|
||||
{
|
||||
common_scripts\utility::waittill_notify_or_timeout( _notify, timeout );
|
||||
}
|
||||
|
||||
Log2Console( logLevel, message )
|
||||
{
|
||||
Print( "[" + logLevel + "] " + message + "\n" );
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
// GUID helpers
|
||||
/////////////////////////////////
|
||||
|
||||
SetPersistentData()
|
||||
{
|
||||
self endon( "disconnect" );
|
||||
|
||||
guidHigh = self GetPlayerData( "bests", "none" );
|
||||
guidLow = self GetPlayerData( "awards", "none" );
|
||||
persistentGuid = guidHigh + "," + guidLow;
|
||||
guidIsStored = guidHigh != 0 && guidLow != 0;
|
||||
|
||||
if ( guidIsStored )
|
||||
{
|
||||
// give IW4MAdmin time to collect IP
|
||||
wait( 15 );
|
||||
scripts\mp\_integration_base::LogDebug( "Uploading persistent guid " + persistentGuid );
|
||||
scripts\mp\_integration_base::SetClientMeta( "PersistentClientGuid", persistentGuid );
|
||||
return;
|
||||
}
|
||||
|
||||
guid = self SplitGuid();
|
||||
|
||||
scripts\mp\_integration_base::LogDebug( "Persisting client guid " + guidHigh + "," + guidLow );
|
||||
|
||||
self SetPlayerData( "bests", "none", guid["high"] );
|
||||
self SetPlayerData( "awards", "none", guid["low"] );
|
||||
}
|
||||
|
||||
SplitGuid()
|
||||
{
|
||||
guid = self GetGuid();
|
||||
|
||||
if ( isDefined( self.guid ) )
|
||||
{
|
||||
guid = self.guid;
|
||||
}
|
||||
|
||||
firstPart = 0;
|
||||
secondPart = 0;
|
||||
stringLength = 17;
|
||||
firstPartExp = 0;
|
||||
secondPartExp = 0;
|
||||
|
||||
for ( i = stringLength - 1; i > 0; i-- )
|
||||
{
|
||||
char = GetSubStr( guid, i - 1, i );
|
||||
if ( char == "" )
|
||||
{
|
||||
char = "0";
|
||||
}
|
||||
|
||||
if ( i > stringLength / 2 )
|
||||
{
|
||||
value = GetIntForHexChar( char );
|
||||
power = Pow( 16, secondPartExp );
|
||||
secondPart = secondPart + ( value * power );
|
||||
secondPartExp++;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = GetIntForHexChar( char );
|
||||
power = Pow( 16, firstPartExp );
|
||||
firstPart = firstPart + ( value * power );
|
||||
firstPartExp++;
|
||||
}
|
||||
}
|
||||
|
||||
split = [];
|
||||
split["low"] = int( secondPart );
|
||||
split["high"] = int( firstPart );
|
||||
|
||||
return split;
|
||||
}
|
||||
|
||||
Pow( num, exponent )
|
||||
{
|
||||
result = 1;
|
||||
while( exponent != 0 )
|
||||
{
|
||||
result = result * num;
|
||||
exponent--;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
GetIntForHexChar( char )
|
||||
{
|
||||
char = ToLower( char );
|
||||
// generated by co-pilot because I can't be bothered to make it more "elegant"
|
||||
switch( char )
|
||||
{
|
||||
case "0":
|
||||
return 0;
|
||||
case "1":
|
||||
return 1;
|
||||
case "2":
|
||||
return 2;
|
||||
case "3":
|
||||
return 3;
|
||||
case "4":
|
||||
return 4;
|
||||
case "5":
|
||||
return 5;
|
||||
case "6":
|
||||
return 6;
|
||||
case "7":
|
||||
return 7;
|
||||
case "8":
|
||||
return 8;
|
||||
case "9":
|
||||
return 9;
|
||||
case "a":
|
||||
return 10;
|
||||
case "b":
|
||||
return 11;
|
||||
case "c":
|
||||
return 12;
|
||||
case "d":
|
||||
return 13;
|
||||
case "e":
|
||||
return 14;
|
||||
case "f":
|
||||
return 15;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
// Command Implementations
|
||||
/////////////////////////////////
|
||||
|
||||
GiveWeaponImpl( event, data )
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
return self.name + "^7 is not alive";
|
||||
}
|
||||
|
||||
self IPrintLnBold( "You have been given a new weapon" );
|
||||
self GiveWeapon( data["weaponName"] );
|
||||
self SwitchToWeapon( data["weaponName"] );
|
||||
|
||||
return self.name + "^7 has been given ^5" + data["weaponName"];
|
||||
}
|
||||
|
||||
TakeWeaponsImpl()
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
return self.name + "^7 is not alive";
|
||||
}
|
||||
|
||||
self TakeAllWeapons();
|
||||
self IPrintLnBold( "All your weapons have been taken" );
|
||||
|
||||
return "Took weapons from " + self.name;
|
||||
}
|
||||
|
||||
TeamSwitchImpl()
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
return self + "^7 is not alive";
|
||||
}
|
||||
|
||||
team = level.allies;
|
||||
|
||||
if ( self.team == "allies" )
|
||||
{
|
||||
team = level.axis;
|
||||
}
|
||||
|
||||
self IPrintLnBold( "You are being team switched" );
|
||||
wait( 2 );
|
||||
self [[team]]();
|
||||
|
||||
return self.name + "^7 switched to " + self.team;
|
||||
}
|
||||
|
||||
LockControlsImpl()
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
return self.name + "^7 is not alive";
|
||||
}
|
||||
|
||||
if ( !IsDefined ( self.isControlLocked ) )
|
||||
{
|
||||
self.isControlLocked = false;
|
||||
}
|
||||
|
||||
if ( !self.isControlLocked )
|
||||
{
|
||||
self freezeControls( true );
|
||||
self God();
|
||||
self Hide();
|
||||
|
||||
info = [];
|
||||
info[ "alertType" ] = "Alert!";
|
||||
info[ "message" ] = "You have been frozen!";
|
||||
|
||||
self AlertImpl( undefined, info );
|
||||
|
||||
self.isControlLocked = true;
|
||||
|
||||
return self.name + "\'s controls are locked";
|
||||
}
|
||||
else
|
||||
{
|
||||
self freezeControls( false );
|
||||
self God();
|
||||
self Show();
|
||||
|
||||
self.isControlLocked = false;
|
||||
|
||||
return self.name + "\'s controls are unlocked";
|
||||
}
|
||||
}
|
||||
|
||||
NoClipImpl()
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
self IPrintLnBold( "You are not alive" );
|
||||
}
|
||||
|
||||
if ( !IsDefined ( self.isNoClipped ) )
|
||||
{
|
||||
self.isNoClipped = false;
|
||||
}
|
||||
|
||||
if ( !self.isNoClipped )
|
||||
{
|
||||
SetDvar( "sv_cheats", 1 );
|
||||
self SetClientDvar( "cg_thirdperson", 1 );
|
||||
|
||||
self God();
|
||||
self Noclip();
|
||||
self Hide();
|
||||
SetDvar( "sv_cheats", 0 );
|
||||
|
||||
self.isNoClipped = true;
|
||||
|
||||
self IPrintLnBold( "NoClip enabled" );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDvar( "sv_cheats", 1 );
|
||||
self SetClientDvar( "cg_thirdperson", 0 );
|
||||
|
||||
self God();
|
||||
self Noclip();
|
||||
self Hide();
|
||||
|
||||
SetDvar( "sv_cheats", 0 );
|
||||
|
||||
self.isNoClipped = false;
|
||||
|
||||
self IPrintLnBold( "NoClip disabled" );
|
||||
}
|
||||
|
||||
self IPrintLnBold( "NoClip enabled" );
|
||||
}
|
||||
|
||||
HideImpl()
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
self IPrintLnBold( "You are not alive" );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !IsDefined ( self.isHidden ) )
|
||||
{
|
||||
self.isHidden = false;
|
||||
}
|
||||
|
||||
if ( !self.isHidden )
|
||||
{
|
||||
SetDvar( "sv_cheats", 1 );
|
||||
self SetClientDvar( "cg_thirdperson", 1 );
|
||||
|
||||
self God();
|
||||
self Hide();
|
||||
SetDvar( "sv_cheats", 0 );
|
||||
|
||||
self.isHidden = true;
|
||||
|
||||
self IPrintLnBold( "Hide enabled" );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDvar( "sv_cheats", 1 );
|
||||
self SetClientDvar( "cg_thirdperson", 0 );
|
||||
|
||||
self God();
|
||||
self Show();
|
||||
SetDvar( "sv_cheats", 0 );
|
||||
|
||||
self.isHidden = false;
|
||||
|
||||
self IPrintLnBold( "Hide disabled" );
|
||||
}
|
||||
}
|
||||
|
||||
AlertImpl( event, data )
|
||||
{
|
||||
if ( level.eventBus.gamename == "IW5" ) {
|
||||
self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( data["alertType"], data["message"], undefined, ( 1, 0, 0 ), "ui_mp_nukebomb_timer", 7.5 );
|
||||
}
|
||||
|
||||
return "Sent alert to " + self.name;
|
||||
}
|
||||
|
||||
GotoImpl( event, data )
|
||||
{
|
||||
if ( IsDefined( event.target ) )
|
||||
{
|
||||
return self GotoPlayerImpl( event.target );
|
||||
}
|
||||
else
|
||||
{
|
||||
return self GotoCoordImpl( data );
|
||||
}
|
||||
}
|
||||
|
||||
GotoCoordImpl( data )
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
self IPrintLnBold( "You are not alive" );
|
||||
return;
|
||||
}
|
||||
|
||||
position = ( int( data["x"] ), int( data["y"] ), int( data["z"]) );
|
||||
self SetOrigin( position );
|
||||
self IPrintLnBold( "Moved to " + "("+ position[0] + "," + position[1] + "," + position[2] + ")" );
|
||||
}
|
||||
|
||||
GotoPlayerImpl( target )
|
||||
{
|
||||
if ( !IsAlive( target ) )
|
||||
{
|
||||
self IPrintLnBold( target.name + " is not alive" );
|
||||
return;
|
||||
}
|
||||
|
||||
self SetOrigin( target GetOrigin() );
|
||||
self IPrintLnBold( "Moved to " + target.name );
|
||||
}
|
||||
|
||||
PlayerToMeImpl( event )
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
return self.name + " is not alive";
|
||||
}
|
||||
|
||||
self SetOrigin( event.origin GetOrigin() );
|
||||
return "Moved here " + self.name;
|
||||
}
|
||||
|
||||
KillImpl()
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
return self.name + " is not alive";
|
||||
}
|
||||
|
||||
self Suicide();
|
||||
self IPrintLnBold( "You were killed by " + self.name );
|
||||
|
||||
return "You killed " + self.name;
|
||||
}
|
||||
|
||||
SetSpectatorImpl()
|
||||
{
|
||||
if ( self.pers["team"] == "spectator" )
|
||||
{
|
||||
return self.name + " is already spectating";
|
||||
}
|
||||
|
||||
self [[level.spectator]]();
|
||||
self IPrintLnBold( "You have been moved to spectator" );
|
||||
|
||||
return self.name + " has been moved to spectator";
|
||||
}
|
522
GameFiles/GameInterface/_integration_t5.gsc
Normal file
522
GameFiles/GameInterface/_integration_t5.gsc
Normal file
@ -0,0 +1,522 @@
|
||||
#include common_scripts\utility;
|
||||
|
||||
Init()
|
||||
{
|
||||
level.eventBus.gamename = "T5";
|
||||
|
||||
level thread Setup();
|
||||
}
|
||||
|
||||
Setup()
|
||||
{
|
||||
level endon( "game_ended" );
|
||||
|
||||
// it's possible that the notify type has not been defined yet so we have to hard code it
|
||||
level waittill( "IntegrationBootstrapInitialized" );
|
||||
|
||||
scripts\mp\_integration_base::RegisterLogger( ::Log2Console );
|
||||
|
||||
level.overrideMethods["GetTotalShotsFired"] = ::GetTotalShotsFired;
|
||||
level.overrideMethods["SetDvarIfUninitialized"] = ::_SetDvarIfUninitialized;
|
||||
level.overrideMethods["waittill_notify_or_timeout"] = ::_waittill_notify_or_timeout;
|
||||
|
||||
RegisterClientCommands();
|
||||
|
||||
level notify( level.notifyTypes.gameFunctionsInitialized );
|
||||
|
||||
if ( GetDvarInt( "sv_iw4madmin_integration_enabled" ) != 1 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
level thread OnPlayerConnect();
|
||||
}
|
||||
|
||||
OnPlayerConnect()
|
||||
{
|
||||
level endon ( "game_ended" );
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
level waittill( "connected", player );
|
||||
|
||||
if ( scripts\mp\_integration_base::_IsBot( player ) )
|
||||
{
|
||||
// we don't want to track bots
|
||||
continue;
|
||||
}
|
||||
|
||||
//player thread SetPersistentData();
|
||||
player thread WaitForClientEvents();
|
||||
}
|
||||
}
|
||||
|
||||
RegisterClientCommands()
|
||||
{
|
||||
scripts\mp\_integration_base::AddClientCommand( "GiveWeapon", true, ::GiveWeaponImpl );
|
||||
scripts\mp\_integration_base::AddClientCommand( "TakeWeapons", true, ::TakeWeaponsImpl );
|
||||
scripts\mp\_integration_base::AddClientCommand( "SwitchTeams", true, ::TeamSwitchImpl );
|
||||
scripts\mp\_integration_base::AddClientCommand( "Hide", false, ::HideImpl );
|
||||
scripts\mp\_integration_base::AddClientCommand( "Alert", true, ::AlertImpl );
|
||||
scripts\mp\_integration_base::AddClientCommand( "Goto", false, ::GotoImpl );
|
||||
scripts\mp\_integration_base::AddClientCommand( "Kill", true, ::KillImpl );
|
||||
scripts\mp\_integration_base::AddClientCommand( "SetSpectator", true, ::SetSpectatorImpl );
|
||||
scripts\mp\_integration_base::AddClientCommand( "LockControls", true, ::LockControlsImpl );
|
||||
scripts\mp\_integration_base::AddClientCommand( "PlayerToMe", true, ::PlayerToMeImpl );
|
||||
scripts\mp\_integration_base::AddClientCommand( "NoClip", false, ::NoClipImpl );
|
||||
}
|
||||
|
||||
WaitForClientEvents()
|
||||
{
|
||||
self endon( "disconnect" );
|
||||
|
||||
// example of requesting a meta value
|
||||
lastServerMetaKey = "LastServerPlayed";
|
||||
// self scripts\mp\_integration_base::RequestClientMeta( lastServerMetaKey );
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
self waittill( level.eventTypes.localClientEvent, event );
|
||||
|
||||
scripts\mp\_integration_base::LogDebug( "Received client event " + event.type );
|
||||
|
||||
if ( event.type == level.eventTypes.clientDataReceived && event.data[0] == lastServerMetaKey )
|
||||
{
|
||||
clientData = self.pers[level.clientDataKey];
|
||||
lastServerPlayed = clientData.meta[lastServerMetaKey];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GetTotalShotsFired()
|
||||
{
|
||||
return maps\mp\gametypes\_persistence::statGet( "total_shots" );
|
||||
}
|
||||
|
||||
_SetDvarIfUninitialized(dvar, value)
|
||||
{
|
||||
maps\mp\_utility::set_dvar_if_unset(dvar, value);
|
||||
}
|
||||
|
||||
_waittill_notify_or_timeout( msg, timer )
|
||||
{
|
||||
self endon( msg );
|
||||
wait( timer );
|
||||
}
|
||||
|
||||
Log2Console( logLevel, message )
|
||||
{
|
||||
Print( "[" + logLevel + "] " + message + "\n" );
|
||||
}
|
||||
|
||||
God()
|
||||
{
|
||||
|
||||
if ( !IsDefined( self.godmode ) )
|
||||
{
|
||||
self.godmode = false;
|
||||
}
|
||||
|
||||
if (!self.godmode )
|
||||
{
|
||||
self enableInvulnerability();
|
||||
self.godmode = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
self.godmode = false;
|
||||
self disableInvulnerability();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
// GUID helpers
|
||||
/////////////////////////////////
|
||||
|
||||
/*SetPersistentData()
|
||||
{
|
||||
self endon( "disconnect" );
|
||||
|
||||
guidHigh = self GetPlayerData( "bests", "none" );
|
||||
guidLow = self GetPlayerData( "awards", "none" );
|
||||
persistentGuid = guidHigh + "," + guidLow;
|
||||
guidIsStored = guidHigh != 0 && guidLow != 0;
|
||||
|
||||
if ( guidIsStored )
|
||||
{
|
||||
// give IW4MAdmin time to collect IP
|
||||
wait( 15 );
|
||||
scripts\mp\_integration_base::LogDebug( "Uploading persistent guid " + persistentGuid );
|
||||
scripts\mp\_integration_base::SetClientMeta( "PersistentClientGuid", persistentGuid );
|
||||
return;
|
||||
}
|
||||
|
||||
guid = self SplitGuid();
|
||||
|
||||
scripts\mp\_integration_base::LogDebug( "Persisting client guid " + guidHigh + "," + guidLow );
|
||||
|
||||
self SetPlayerData( "bests", "none", guid["high"] );
|
||||
self SetPlayerData( "awards", "none", guid["low"] );
|
||||
}
|
||||
|
||||
SplitGuid()
|
||||
{
|
||||
guid = self GetGuid();
|
||||
|
||||
if ( isDefined( self.guid ) )
|
||||
{
|
||||
guid = self.guid;
|
||||
}
|
||||
|
||||
firstPart = 0;
|
||||
secondPart = 0;
|
||||
stringLength = 17;
|
||||
firstPartExp = 0;
|
||||
secondPartExp = 0;
|
||||
|
||||
for ( i = stringLength - 1; i > 0; i-- )
|
||||
{
|
||||
char = GetSubStr( guid, i - 1, i );
|
||||
if ( char == "" )
|
||||
{
|
||||
char = "0";
|
||||
}
|
||||
|
||||
if ( i > stringLength / 2 )
|
||||
{
|
||||
value = GetIntForHexChar( char );
|
||||
power = Pow( 16, secondPartExp );
|
||||
secondPart = secondPart + ( value * power );
|
||||
secondPartExp++;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = GetIntForHexChar( char );
|
||||
power = Pow( 16, firstPartExp );
|
||||
firstPart = firstPart + ( value * power );
|
||||
firstPartExp++;
|
||||
}
|
||||
}
|
||||
|
||||
split = [];
|
||||
split["low"] = int( secondPart );
|
||||
split["high"] = int( firstPart );
|
||||
|
||||
return split;
|
||||
}
|
||||
|
||||
Pow( num, exponent )
|
||||
{
|
||||
result = 1;
|
||||
while( exponent != 0 )
|
||||
{
|
||||
result = result * num;
|
||||
exponent--;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
GetIntForHexChar( char )
|
||||
{
|
||||
char = ToLower( char );
|
||||
// generated by co-pilot because I can't be bothered to make it more "elegant"
|
||||
switch( char )
|
||||
{
|
||||
case "0":
|
||||
return 0;
|
||||
case "1":
|
||||
return 1;
|
||||
case "2":
|
||||
return 2;
|
||||
case "3":
|
||||
return 3;
|
||||
case "4":
|
||||
return 4;
|
||||
case "5":
|
||||
return 5;
|
||||
case "6":
|
||||
return 6;
|
||||
case "7":
|
||||
return 7;
|
||||
case "8":
|
||||
return 8;
|
||||
case "9":
|
||||
return 9;
|
||||
case "a":
|
||||
return 10;
|
||||
case "b":
|
||||
return 11;
|
||||
case "c":
|
||||
return 12;
|
||||
case "d":
|
||||
return 13;
|
||||
case "e":
|
||||
return 14;
|
||||
case "f":
|
||||
return 15;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}*/
|
||||
|
||||
//////////////////////////////////
|
||||
// Command Implementations
|
||||
/////////////////////////////////
|
||||
|
||||
GiveWeaponImpl( event, data )
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
return self.name + "^7 is not alive";
|
||||
}
|
||||
|
||||
self IPrintLnBold( "You have been given a new weapon" );
|
||||
self GiveWeapon( data["weaponName"] );
|
||||
self SwitchToWeapon( data["weaponName"] );
|
||||
|
||||
return self.name + "^7 has been given ^5" + data["weaponName"];
|
||||
}
|
||||
|
||||
TakeWeaponsImpl( event, data )
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
return self.name + "^7 is not alive";
|
||||
}
|
||||
|
||||
self TakeAllWeapons();
|
||||
self IPrintLnBold( "All your weapons have been taken" );
|
||||
|
||||
return "Took weapons from " + self.name;
|
||||
}
|
||||
|
||||
TeamSwitchImpl( event, data )
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
return self + "^7 is not alive";
|
||||
}
|
||||
|
||||
team = level.allies;
|
||||
|
||||
if ( self.team == "allies" )
|
||||
{
|
||||
team = level.axis;
|
||||
}
|
||||
|
||||
self IPrintLnBold( "You are being team switched" );
|
||||
wait( 2 );
|
||||
self [[team]]();
|
||||
|
||||
return self.name + "^7 switched to " + self.team;
|
||||
}
|
||||
|
||||
LockControlsImpl( event, data )
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
return self.name + "^7 is not alive";
|
||||
}
|
||||
|
||||
if ( !IsDefined ( self.isControlLocked ) )
|
||||
{
|
||||
self.isControlLocked = false;
|
||||
}
|
||||
|
||||
if ( !self.isControlLocked )
|
||||
{
|
||||
self freezeControls( true );
|
||||
self God();
|
||||
self Hide();
|
||||
|
||||
info = [];
|
||||
info[ "alertType" ] = "Alert!";
|
||||
info[ "message" ] = "You have been frozen!";
|
||||
|
||||
self AlertImpl( undefined, info );
|
||||
|
||||
self.isControlLocked = true;
|
||||
|
||||
return self.name + "\'s controls are locked";
|
||||
}
|
||||
else
|
||||
{
|
||||
self freezeControls( false );
|
||||
self God();
|
||||
self Show();
|
||||
|
||||
self.isControlLocked = false;
|
||||
|
||||
return self.name + "\'s controls are unlocked";
|
||||
}
|
||||
}
|
||||
|
||||
NoClipImpl( event, data )
|
||||
{
|
||||
/*if ( !IsAlive( self ) )
|
||||
{
|
||||
self IPrintLnBold( "You are not alive" );
|
||||
}
|
||||
|
||||
if ( !IsDefined ( self.isNoClipped ) )
|
||||
{
|
||||
self.isNoClipped = false;
|
||||
}
|
||||
|
||||
if ( !self.isNoClipped )
|
||||
{
|
||||
self SetClientDvar( "sv_cheats", 1 );
|
||||
self SetClientDvar( "cg_thirdperson", 1 );
|
||||
self SetClientDvar( "sv_cheats", 0 );
|
||||
|
||||
self God();
|
||||
self Noclip();
|
||||
self Hide();
|
||||
|
||||
self.isNoClipped = true;
|
||||
|
||||
self IPrintLnBold( "NoClip enabled" );
|
||||
}
|
||||
else
|
||||
{
|
||||
self SetClientDvar( "sv_cheats", 1 );
|
||||
self SetClientDvar( "cg_thirdperson", 1 );
|
||||
self SetClientDvar( "sv_cheats", 0 );
|
||||
|
||||
self God();
|
||||
self Noclip();
|
||||
self Hide();
|
||||
|
||||
self.isNoClipped = false;
|
||||
|
||||
self IPrintLnBold( "NoClip disabled" );
|
||||
}
|
||||
|
||||
self IPrintLnBold( "NoClip enabled" );*/
|
||||
|
||||
scripts\mp\_integration_base::LogWarning( "NoClip is not supported on T5!" );
|
||||
|
||||
}
|
||||
|
||||
HideImpl( event, data )
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
self IPrintLnBold( "You are not alive" );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !IsDefined ( self.isHidden ) )
|
||||
{
|
||||
self.isHidden = false;
|
||||
}
|
||||
|
||||
if ( !self.isHidden )
|
||||
{
|
||||
self SetClientDvar( "sv_cheats", 1 );
|
||||
self SetClientDvar( "cg_thirdperson", 1 );
|
||||
self SetClientDvar( "sv_cheats", 0 );
|
||||
|
||||
self God();
|
||||
self Hide();
|
||||
|
||||
self.isHidden = true;
|
||||
|
||||
self IPrintLnBold( "Hide enabled" );
|
||||
}
|
||||
else
|
||||
{
|
||||
self SetClientDvar( "sv_cheats", 1 );
|
||||
self SetClientDvar( "cg_thirdperson", 0 );
|
||||
self SetClientDvar( "sv_cheats", 0 );
|
||||
|
||||
self God();
|
||||
self Show();
|
||||
|
||||
self.isHidden = false;
|
||||
|
||||
self IPrintLnBold( "Hide disabled" );
|
||||
}
|
||||
}
|
||||
|
||||
AlertImpl( event, data )
|
||||
{
|
||||
self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( data["alertType"], data["message"], undefined, ( 1, 0, 0 ), "mpl_sab_ui_suitcasebomb_timer", 7.5 );
|
||||
|
||||
return "Sent alert to " + self.name;
|
||||
}
|
||||
|
||||
GotoImpl( event, data )
|
||||
{
|
||||
if ( IsDefined( event.target ) )
|
||||
{
|
||||
return self GotoPlayerImpl( event.target );
|
||||
}
|
||||
else
|
||||
{
|
||||
return self GotoCoordImpl( data );
|
||||
}
|
||||
}
|
||||
|
||||
GotoCoordImpl( data )
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
self IPrintLnBold( "You are not alive" );
|
||||
return;
|
||||
}
|
||||
|
||||
position = ( int( data["x"] ), int( data["y"] ), int( data["z"]) );
|
||||
self SetOrigin( position );
|
||||
self IPrintLnBold( "Moved to " + "("+ position[0] + "," + position[1] + "," + position[2] + ")" );
|
||||
}
|
||||
|
||||
GotoPlayerImpl( target )
|
||||
{
|
||||
if ( !IsAlive( target ) )
|
||||
{
|
||||
self IPrintLnBold( target.name + " is not alive" );
|
||||
return;
|
||||
}
|
||||
|
||||
self SetOrigin( target GetOrigin() );
|
||||
self IPrintLnBold( "Moved to " + target.name );
|
||||
}
|
||||
|
||||
PlayerToMeImpl( event, data )
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
return self.name + " is not alive";
|
||||
}
|
||||
|
||||
self SetOrigin( event.origin GetOrigin() );
|
||||
return "Moved here " + self.name;
|
||||
}
|
||||
|
||||
KillImpl( event, data )
|
||||
{
|
||||
if ( !IsAlive( self ) )
|
||||
{
|
||||
return self.name + " is not alive";
|
||||
}
|
||||
|
||||
self Suicide();
|
||||
self IPrintLnBold( "You were killed by " + self.name );
|
||||
|
||||
return "You killed " + self.name;
|
||||
}
|
||||
|
||||
SetSpectatorImpl( event, data )
|
||||
{
|
||||
if ( self.pers["team"] == "spectator" )
|
||||
{
|
||||
return self.name + " is already spectating";
|
||||
}
|
||||
|
||||
self [[level.spectator]]();
|
||||
self IPrintLnBold( "You have been moved to spectator" );
|
||||
|
||||
return self.name + " has been moved to spectator";
|
||||
}
|
16
GameFiles/README.MD
Normal file
16
GameFiles/README.MD
Normal file
@ -0,0 +1,16 @@
|
||||
# Game Interface
|
||||
|
||||
Allows integration of IW4M-Admin to GSC, mainly used for special commands that need to use GSC in order to work.
|
||||
But can also be used to read / write metadata from / to a profile and to get the player permission level.
|
||||
|
||||
|
||||
## Installation Plutonium IW5
|
||||
|
||||
|
||||
Move `_integration.gsc` to `%localappdata%\Plutonium\storage\iw5\scripts\`
|
||||
|
||||
|
||||
## Installation IW4x
|
||||
|
||||
|
||||
Move `_integration.gsc` to `IW4x/userraw/scripts`, `IW4x` being the root folder of your game server.
|
14
GameFiles/deploy.bat
Normal file
14
GameFiles/deploy.bat
Normal file
@ -0,0 +1,14 @@
|
||||
@echo off
|
||||
|
||||
ECHO "Pluto IW5"
|
||||
xcopy /y .\GameInterface\_integration_base.gsc "%LOCALAPPDATA%\Plutonium\storage\iw5\scripts\mp"
|
||||
xcopy /y .\GameInterface\_integration_iw5.gsc "%LOCALAPPDATA%\Plutonium\storage\iw5\scripts\mp"
|
||||
xcopy /y .\AntiCheat\IW5\storage\iw5\scripts\_customcallbacks.gsc "%LOCALAPPDATA%\Plutonium\storage\iw5\scripts\mp"
|
||||
|
||||
ECHO "Pluto T5"
|
||||
xcopy /y .\GameInterface\_integration_base.gsc "%LOCALAPPDATA%\Plutonium\storage\t5\scripts\mp"
|
||||
xcopy /y .\GameInterface\_integration_t5.gsc "%LOCALAPPDATA%\Plutonium\storage\t5\scripts\mp"
|
||||
|
||||
ECHO "Pluto T6"
|
||||
xcopy /y .\AntiCheat\PT6\storage\t6\scripts\mp\_customcallbacks.gsc "%LOCALAPPDATA%\Plutonium\storage\t6\scripts\mp"
|
||||
xcopy /y .\AntiCheat\PT6\storage\t6\scripts\mp\_customcallbacks.gsc.src "%LOCALAPPDATA%\Plutonium\storage\t6\scripts\mp"
|
@ -6,14 +6,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{26E8
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8C8F3945-0AEF-4949-A1F7-B18E952E50BC}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
GameFiles\IW4x\userraw\scripts\_customcallbacks.gsc = GameFiles\IW4x\userraw\scripts\_customcallbacks.gsc
|
||||
DeploymentFiles\deployment-pipeline.yml = DeploymentFiles\deployment-pipeline.yml
|
||||
DeploymentFiles\PostPublish.ps1 = DeploymentFiles\PostPublish.ps1
|
||||
README.md = README.md
|
||||
version.txt = version.txt
|
||||
DeploymentFiles\UpdateIW4MAdmin.ps1 = DeploymentFiles\UpdateIW4MAdmin.ps1
|
||||
DeploymentFiles\UpdateIW4MAdmin.sh = DeploymentFiles\UpdateIW4MAdmin.sh
|
||||
GameFiles\IW4x\userraw\scripts\_integration.gsc = GameFiles\IW4x\userraw\scripts\_integration.gsc
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharedLibraryCore", "SharedLibraryCore\SharedLibraryCore.csproj", "{AA0541A2-8D51-4AD9-B0AC-3D1F5B162481}"
|
||||
@ -51,6 +49,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ScriptPlugins", "ScriptPlug
|
||||
Plugins\ScriptPlugins\ParserCSGOSM.js = Plugins\ScriptPlugins\ParserCSGOSM.js
|
||||
Plugins\ScriptPlugins\ParserPlutoniumT4COZM.js = Plugins\ScriptPlugins\ParserPlutoniumT4COZM.js
|
||||
Plugins\ScriptPlugins\GameInterface.js = Plugins\ScriptPlugins\GameInterface.js
|
||||
Plugins\ScriptPlugins\SubnetBan.js = Plugins\ScriptPlugins\SubnetBan.js
|
||||
Plugins\ScriptPlugins\BanBroadcasting.js = Plugins\ScriptPlugins\BanBroadcasting.js
|
||||
Plugins\ScriptPlugins\ParserH1MOD.js = Plugins\ScriptPlugins\ParserH1MOD.js
|
||||
Plugins\ScriptPlugins\ParserPlutoniumT5.js = Plugins\ScriptPlugins\ParserPlutoniumT5.js
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutomessageFeed", "Plugins\AutomessageFeed\AutomessageFeed.csproj", "{F5815359-CFC7-44B4-9A3B-C04BACAD5836}"
|
||||
@ -67,6 +69,36 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Integrations.Cod", "Integra
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Integrations.Source", "Integrations\Source\Integrations.Source.csproj", "{9512295B-3045-40E0-9B7E-2409F2173E9D}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mute", "Plugins\Mute\Mute.csproj", "{259824F3-D860-4233-91D6-FF73D4DD8B18}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GameFiles", "GameFiles", "{6CBF412C-EFEE-45F7-80FD-AC402C22CDB9}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GameInterface", "GameInterface", "{5C2BE2A8-EA1D-424F-88E1-7FC33EEC2E55}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
GameFiles\GameInterface\_integration_base.gsc = GameFiles\GameInterface\_integration_base.gsc
|
||||
GameFiles\GameInterface\_integration_iw4x.gsc = GameFiles\GameInterface\_integration_iw4x.gsc
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AntiCheat", "AntiCheat", "{AB83BAC0-C539-424A-BF00-78487C10753C}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "IW4x", "IW4x", "{3EA564BD-3AC6-479B-96B6-CB059DCD0C77}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
GameFiles\AntiCheat\IW4x\userraw\scripts\_customcallbacks.gsc = GameFiles\AntiCheat\IW4x\userraw\scripts\_customcallbacks.gsc
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Pluto T6", "Pluto T6", "{866F453D-BC89-457F-8B55-485494759B31}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
GameFiles\AntiCheat\PT6\storage\t6\scripts\mp\_customcallbacks.gsc = GameFiles\AntiCheat\PT6\storage\t6\scripts\mp\_customcallbacks.gsc
|
||||
GameFiles\AntiCheat\PT6\storage\t6\scripts\mp\_customcallbacks.gsc.src = GameFiles\AntiCheat\PT6\storage\t6\scripts\mp\_customcallbacks.gsc.src
|
||||
GameFiles\AntiCheat\PT6\README.MD = GameFiles\AntiCheat\PT6\README.MD
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Pluto IW5", "Pluto IW5", "{603725A4-BC0B-423B-955B-762C89E1C4C2}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
GameFiles\AntiCheat\IW5\storage\iw5\scripts\_customcallbacks.gsc = GameFiles\AntiCheat\IW5\storage\iw5\scripts\_customcallbacks.gsc
|
||||
GameFiles\AntiCheat\IW5\README.MD = GameFiles\AntiCheat\IW5\README.MD
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -371,6 +403,30 @@ Global
|
||||
{9512295B-3045-40E0-9B7E-2409F2173E9D}.Release|x86.Build.0 = Release|Any CPU
|
||||
{9512295B-3045-40E0-9B7E-2409F2173E9D}.Prerelease|Any CPU.ActiveCfg = Prerelease|Any CPU
|
||||
{9512295B-3045-40E0-9B7E-2409F2173E9D}.Prerelease|Any CPU.Build.0 = Prerelease|Any CPU
|
||||
{259824F3-D860-4233-91D6-FF73D4DD8B18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{259824F3-D860-4233-91D6-FF73D4DD8B18}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{259824F3-D860-4233-91D6-FF73D4DD8B18}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{259824F3-D860-4233-91D6-FF73D4DD8B18}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{259824F3-D860-4233-91D6-FF73D4DD8B18}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{259824F3-D860-4233-91D6-FF73D4DD8B18}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{259824F3-D860-4233-91D6-FF73D4DD8B18}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{259824F3-D860-4233-91D6-FF73D4DD8B18}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{259824F3-D860-4233-91D6-FF73D4DD8B18}.Prerelease|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{259824F3-D860-4233-91D6-FF73D4DD8B18}.Prerelease|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{259824F3-D860-4233-91D6-FF73D4DD8B18}.Prerelease|x64.ActiveCfg = Debug|Any CPU
|
||||
{259824F3-D860-4233-91D6-FF73D4DD8B18}.Prerelease|x64.Build.0 = Debug|Any CPU
|
||||
{259824F3-D860-4233-91D6-FF73D4DD8B18}.Prerelease|x86.ActiveCfg = Debug|Any CPU
|
||||
{259824F3-D860-4233-91D6-FF73D4DD8B18}.Prerelease|x86.Build.0 = Debug|Any CPU
|
||||
{259824F3-D860-4233-91D6-FF73D4DD8B18}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{259824F3-D860-4233-91D6-FF73D4DD8B18}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{259824F3-D860-4233-91D6-FF73D4DD8B18}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{259824F3-D860-4233-91D6-FF73D4DD8B18}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{259824F3-D860-4233-91D6-FF73D4DD8B18}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{259824F3-D860-4233-91D6-FF73D4DD8B18}.Release|x64.Build.0 = Release|Any CPU
|
||||
{259824F3-D860-4233-91D6-FF73D4DD8B18}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{259824F3-D860-4233-91D6-FF73D4DD8B18}.Release|x86.Build.0 = Release|Any CPU
|
||||
{259824F3-D860-4233-91D6-FF73D4DD8B18}.Prerelease|Any CPU.ActiveCfg = Prerelease|Any CPU
|
||||
{259824F3-D860-4233-91D6-FF73D4DD8B18}.Prerelease|Any CPU.Build.0 = Prerelease|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@ -385,6 +441,13 @@ Global
|
||||
{00A1FED2-2254-4AF7-A5DB-2357FA7C88CD} = {26E8B310-269E-46D4-A612-24601F16065F}
|
||||
{A9348433-58C1-4B9C-8BB7-088B02529D9D} = {A2AE33B4-0830-426A-9E11-951DAB12BE5B}
|
||||
{9512295B-3045-40E0-9B7E-2409F2173E9D} = {A2AE33B4-0830-426A-9E11-951DAB12BE5B}
|
||||
{259824F3-D860-4233-91D6-FF73D4DD8B18} = {26E8B310-269E-46D4-A612-24601F16065F}
|
||||
{6CBF412C-EFEE-45F7-80FD-AC402C22CDB9} = {8C8F3945-0AEF-4949-A1F7-B18E952E50BC}
|
||||
{5C2BE2A8-EA1D-424F-88E1-7FC33EEC2E55} = {6CBF412C-EFEE-45F7-80FD-AC402C22CDB9}
|
||||
{AB83BAC0-C539-424A-BF00-78487C10753C} = {6CBF412C-EFEE-45F7-80FD-AC402C22CDB9}
|
||||
{3EA564BD-3AC6-479B-96B6-CB059DCD0C77} = {AB83BAC0-C539-424A-BF00-78487C10753C}
|
||||
{866F453D-BC89-457F-8B55-485494759B31} = {AB83BAC0-C539-424A-BF00-78487C10753C}
|
||||
{603725A4-BC0B-423B-955B-762C89E1C4C2} = {AB83BAC0-C539-424A-BF00-78487C10753C}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {84F8F8E0-1F73-41E0-BD8D-BB6676E2EE87}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user