Finish dynamic dvar parsing for IW4x
This commit is contained in:
@ -2,12 +2,10 @@
|
||||
{
|
||||
public class Dvar<T>
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
public T Value;
|
||||
|
||||
public Dvar(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
public string Name { get; set; }
|
||||
public T Value { get; set; }
|
||||
public T DefaultValue { get; set; }
|
||||
public T LatchedValue { get; set; }
|
||||
public string Domain { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,11 @@ namespace SharedLibraryCore.Interfaces
|
||||
RConNetworkId = 103,
|
||||
RConName = 104,
|
||||
RConIpAddress = 105,
|
||||
RConDvarName = 106,
|
||||
RConDvarValue = 107,
|
||||
RConDvarDefaultValue = 108,
|
||||
RConDvarLatchedValue = 109,
|
||||
RConDvarDomain = 110,
|
||||
AdditionalGroup = 200
|
||||
}
|
||||
public string Pattern { get; set; }
|
||||
|
@ -7,5 +7,6 @@ namespace SharedLibraryCore.Interfaces
|
||||
CommandPrefix CommandPrefixes { get; set; }
|
||||
Server.Game GameName { get; set; }
|
||||
ParserRegex Status { get; set; }
|
||||
ParserRegex Dvar { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -433,9 +433,9 @@ namespace SharedLibraryCore.Database.Models
|
||||
}
|
||||
|
||||
// reserved slots stuff
|
||||
// todo: is this broken on T6?
|
||||
// todo: bots don't seem to honor party_maxplayers/sv_maxclients
|
||||
if (CurrentServer.MaxClients - (CurrentServer.GetClientsAsList().Count(_client => !_client.IsPrivileged())) < CurrentServer.ServerConfig.ReservedSlotNumber &&
|
||||
!this.IsPrivileged() && CurrentServer.GameName != Server.Game.T6M /* HACK: temporary */)
|
||||
!this.IsPrivileged())
|
||||
{
|
||||
CurrentServer.Logger.WriteDebug($"Kicking {this} their spot is reserved");
|
||||
Kick(loc["SERVER_KICK_SLOT_IS_RESERVED"], Utilities.IW4MAdminClient(CurrentServer));
|
||||
@ -461,9 +461,10 @@ namespace SharedLibraryCore.Database.Models
|
||||
|
||||
if (ipAddress != null)
|
||||
{
|
||||
if (IPAddressString == "66.150.121.184")
|
||||
// todo: remove this in a few weeks because it's just temporary for server forwarding
|
||||
if (IPAddressString == "66.150.121.184" || IPAddressString == "62.210.178.177")
|
||||
{
|
||||
Kick("Your favorite servers are outdated. Please re-add the server.", autoKickClient);
|
||||
Kick($"Your favorite servers are outdated. Please remove and re-add this server. ({CurrentServer.Hostname})", autoKickClient);
|
||||
return false;
|
||||
}
|
||||
await CurrentServer.Manager.GetClientService().UpdateAlias(this);
|
||||
|
@ -13,5 +13,9 @@ namespace SharedLibraryCore.RCon
|
||||
public string Ban { get; set; }
|
||||
public string Unban { get; set; }
|
||||
public string TempBan { get; set; }
|
||||
public string RConQuery { get; set; }
|
||||
public string RConGetStatus { get; set; }
|
||||
public string RConGetInfo { get; set; }
|
||||
public string RConResponse { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -30,12 +30,19 @@ namespace SharedLibraryCore.RCon
|
||||
public string RConPassword { get; private set; }
|
||||
|
||||
private readonly ILogger Log;
|
||||
private IRConParserConfiguration Config;
|
||||
|
||||
public Connection(string ipAddress, int port, string password, ILogger log)
|
||||
public Connection(string ipAddress, int port, string password, ILogger log, IRConParserConfiguration config)
|
||||
{
|
||||
Endpoint = new IPEndPoint(IPAddress.Parse(ipAddress), port);
|
||||
RConPassword = password;
|
||||
Log = log;
|
||||
Config = config;
|
||||
}
|
||||
|
||||
public void SetConfiguration(IRConParserConfiguration config)
|
||||
{
|
||||
Config = config;
|
||||
}
|
||||
|
||||
public async Task<string[]> SendQueryAsync(StaticHelpers.QueryType type, string parameters = "", bool waitForResponse = true)
|
||||
@ -73,16 +80,14 @@ namespace SharedLibraryCore.RCon
|
||||
{
|
||||
case StaticHelpers.QueryType.DVAR:
|
||||
case StaticHelpers.QueryType.COMMAND:
|
||||
var header = "ÿÿÿÿrcon ".Select(Convert.ToByte).ToList();
|
||||
byte[] p = Utilities.EncodingType.GetBytes($"{RConPassword} {parameters}");
|
||||
header.AddRange(p);
|
||||
payload = header.ToArray();
|
||||
payload = Utilities.EncodingType
|
||||
.GetBytes(string.Format(Config.CommandPrefixes.RConQuery, RConPassword, parameters + '\0'));
|
||||
break;
|
||||
case StaticHelpers.QueryType.GET_STATUS:
|
||||
payload = "ÿÿÿÿgetstatus".Select(Convert.ToByte).ToArray();
|
||||
payload = (Config.CommandPrefixes.RConGetStatus + '\0').Select(Convert.ToByte).ToArray();
|
||||
break;
|
||||
case StaticHelpers.QueryType.GET_INFO:
|
||||
payload = "ÿÿÿÿgetinfo".Select(Convert.ToByte).ToArray();
|
||||
payload = (Config.CommandPrefixes.RConGetInfo + '\0').Select(Convert.ToByte).ToArray();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ namespace SharedLibraryCore
|
||||
Logger = Manager.GetLogger(this.EndPoint);
|
||||
Logger.WriteInfo(this.ToString());
|
||||
ServerConfig = config;
|
||||
RemoteConnection = new RCon.Connection(IP, Port, Password, Logger);
|
||||
RemoteConnection = new RCon.Connection(IP, Port, Password, Logger, null);
|
||||
|
||||
Clients = new List<EFClient>(new EFClient[18]);
|
||||
Reports = new List<Report>();
|
||||
|
@ -347,6 +347,11 @@ namespace SharedLibraryCore
|
||||
|
||||
public static Game GetGame(string gameName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(gameName))
|
||||
{
|
||||
return Game.UKN;
|
||||
}
|
||||
|
||||
if (gameName.Contains("IW4"))
|
||||
{
|
||||
return Game.IW4;
|
||||
|
Reference in New Issue
Block a user