move IW3 parser to javascript

This commit is contained in:
RaidMax 2019-02-02 20:19:24 -06:00
parent 0a1dc46760
commit e6bfa408f8
6 changed files with 61 additions and 66 deletions

View File

@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace IW4MAdmin.Application.EventParsers
{
class IW3EventParser : BaseEventParser
{
public IW3EventParser() : base()
{
Configuration.GameDirectory = "main";
}
}
}

View File

@ -665,31 +665,22 @@ namespace IW4MAdmin
public async Task Initialize()
{
var rconParser = Manager.AdditionalRConParsers
RconParser = Manager.AdditionalRConParsers
.FirstOrDefault(_parser => _parser.Version == Manager.GetApplicationSettings().Configuration().CustomParserVersion);
var eventParser = Manager.AdditionalEventParsers
EventParser = Manager.AdditionalEventParsers
.FirstOrDefault(_parser => _parser.Version == Manager.GetApplicationSettings().Configuration().CustomParserVersion);
rconParser = rconParser ?? new BaseRConParser();
eventParser = eventParser ?? new BaseEventParser();
RconParser = RconParser ?? new BaseRConParser();
EventParser = EventParser ?? new BaseEventParser();
RemoteConnection.SetConfiguration(rconParser.Configuration);
RconParser = rconParser;
EventParser = eventParser;
RemoteConnection.SetConfiguration(RconParser.Configuration);
var version = await this.GetDvarAsync<string>("version");
Version = version.Value;
GameName = Utilities.GetGame(version?.Value);
if (GameName == Game.IW4)
{
EventParser = new BaseEventParser();
RconParser = new BaseRConParser();
}
else if (GameName == Game.T5M)
if (GameName == Game.T5M)
{
EventParser = new T5MEventParser();
}
@ -699,18 +690,11 @@ namespace IW4MAdmin
EventParser = new T6MEventParser();
}
//else
//{
// EventParser = new IW3EventParser(); // this uses the 'main' folder for log paths
//}
//if (GameName == Game.UKN)
//{
// Logger.WriteWarning($"Game name not recognized: {version}");
// EventParser = Manager.AdditionalEventParsers.FirstOrDefault(_parser => _parser.Version == version.Value) ?? EventParser;
// RconParser = Manager.AdditionalRConParsers.FirstOrDefault(_parser => (_parser as DynamicRConParser).Version == version.Value) ?? RconParser;
//}
else if (version.Value.Length != 0)
{
RconParser = Manager.AdditionalRConParsers.FirstOrDefault(_parser => _parser.Version == version.Value) ?? RconParser;
EventParser = Manager.AdditionalEventParsers.First(_parser => _parser.Version == version.Value) ?? EventParser;
}
var infoResponse = RconParser.Configuration.CommandPrefixes.RConGetInfo != null ? await this.GetInfoAsync() : null;
// this is normally slow, but I'm only doing it because different games have different prefixes

View File

@ -1,25 +0,0 @@
using SharedLibraryCore;
using SharedLibraryCore.RCon;
using System;
using System.Collections.Generic;
using System.Text;
namespace IW4MAdmin.Application.RconParsers
{
class IW3RConParser : BaseRConParser
{
public IW3RConParser() : base()
{
Configuration.CommandPrefixes = new CommandPrefix()
{
Tell = "tell {0} {1}",
Say = "say {0}",
Kick = "clientkick {0} \"{1}\"",
Ban = "clientkick {0} \"{1}\"",
TempBan = "tempbanclient {0} \"{1}\""
};
Configuration.GameName = Server.Game.IW3;
}
}
}

View File

@ -38,6 +38,7 @@ Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "DiscordWebhook", "DiscordWe
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ScriptPlugins", "ScriptPlugins", "{3F9ACC27-26DB-49FA-BCD2-50C54A49C9FA}"
ProjectSection(SolutionItems) = preProject
Plugins\ScriptPlugins\ParserIW3.js = Plugins\ScriptPlugins\ParserIW3.js
Plugins\ScriptPlugins\ParserTeknoMW3.js = Plugins\ScriptPlugins\ParserTeknoMW3.js
Plugins\ScriptPlugins\SharedGUIDKick.js = Plugins\ScriptPlugins\SharedGUIDKick.js
Plugins\ScriptPlugins\VPNDetection.js = Plugins\ScriptPlugins\VPNDetection.js

View File

@ -0,0 +1,33 @@
var rconParser;
var eventParser;
var plugin = {
author: 'RaidMax',
version: 0.1,
name: 'IW3 Parser',
isParser: true,
onEventAsync: function (gameEvent, server) {
},
onLoadAsync: function (manager) {
rconParser = manager.GenerateDynamicRConParser();
eventParser = manager.GenerateDynamicEventParser();
rconParser.Configuration.CommandPrefixes.Tell = 'tell {0} {1}';
rconParser.Configuration.CommandPrefixes.Say = 'say {0}';
rconParser.Configuration.CommandPrefixes.Kick = 'clientkick {0} "{1}"';
rconParser.Configuration.CommandPrefixes.Ban = 'clientkick {0} "{1}"';
rconParser.Configuration.CommandPrefixes.TempBan = 'tempbanclient {0} "{1}"';
rconParser.Version = 'CoD4 MP 1.8 build 13620 Thu Oct 04 00:43:04 2007 win-x86';
eventParser.Configuration.GameDirectory = 'main';
eventParser.Version = 'CoD4 MP 1.8 build 13620 Thu Oct 04 00:43:04 2007 win-x86';
},
onUnloadAsync: function () {
},
onTickAsync: function (server) {
}
};

View File

@ -71,6 +71,22 @@ namespace SharedLibraryCore.Interfaces
GroupMapping.Add((GroupType)key, value);
}
}
if (mapKey.GetType() == typeof(GroupType) && mapValue.GetType().ToString() == "System.Int32")
{
GroupType k = (GroupType)Enum.Parse(typeof(GroupType), mapKey.ToString());
int v = int.Parse(mapValue.ToString());
if (GroupMapping.ContainsKey(k))
{
GroupMapping[k] = v;
}
else
{
GroupMapping.Add(k, v);
}
}
}
public ParserRegex()