2015-08-20 01:06:44 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2017-05-26 18:49:27 -04:00
|
|
|
|
using System.Runtime.InteropServices;
|
2015-08-20 01:06:44 -04:00
|
|
|
|
using System.Text;
|
2017-05-26 18:49:27 -04:00
|
|
|
|
using System.Threading;
|
|
|
|
|
|
|
|
|
|
using SharedLibrary.Network;
|
|
|
|
|
using SharedLibrary.Commands;
|
|
|
|
|
using System.Threading.Tasks;
|
2017-11-02 12:49:45 -04:00
|
|
|
|
using SharedLibrary.Helpers;
|
2017-11-25 20:29:58 -05:00
|
|
|
|
using SharedLibrary.Objects;
|
2018-02-23 02:06:13 -05:00
|
|
|
|
using SharedLibrary.Dtos;
|
2015-08-20 01:06:44 -04:00
|
|
|
|
|
|
|
|
|
namespace SharedLibrary
|
|
|
|
|
{
|
2017-05-26 18:49:27 -04:00
|
|
|
|
[Guid("61d3829e-fcbe-44d3-bb7c-51db8c2d7ac5")]
|
2015-08-20 01:06:44 -04:00
|
|
|
|
public abstract class Server
|
|
|
|
|
{
|
2017-08-08 22:44:52 -04:00
|
|
|
|
public enum Game
|
|
|
|
|
{
|
|
|
|
|
UKN,
|
|
|
|
|
IW3,
|
|
|
|
|
IW4,
|
|
|
|
|
IW5,
|
|
|
|
|
T4,
|
|
|
|
|
T5,
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public Server(Interfaces.IManager mgr, ServerConfiguration config)
|
2015-08-20 01:06:44 -04:00
|
|
|
|
{
|
2017-06-19 13:58:01 -04:00
|
|
|
|
Password = config.Password;
|
|
|
|
|
IP = config.IP;
|
|
|
|
|
Port = config.Port;
|
2017-05-26 18:49:27 -04:00
|
|
|
|
Manager = mgr;
|
2017-05-27 19:29:20 -04:00
|
|
|
|
Logger = Manager.GetLogger();
|
2017-06-19 13:58:01 -04:00
|
|
|
|
Config = config;
|
2015-08-20 01:06:44 -04:00
|
|
|
|
|
2017-05-26 18:49:27 -04:00
|
|
|
|
Players = new List<Player>(new Player[18]);
|
2015-08-20 01:06:44 -04:00
|
|
|
|
Reports = new List<Report>();
|
2017-06-16 17:35:51 -04:00
|
|
|
|
PlayerHistory = new Queue<Helpers.PlayerHistory>();
|
2017-06-07 20:59:59 -04:00
|
|
|
|
ChatHistory = new List<Chat>();
|
2018-02-10 23:33:42 -05:00
|
|
|
|
//Configuration = new ConfigurationManager(this.GetType());
|
2017-06-19 13:58:01 -04:00
|
|
|
|
NextMessage = 0;
|
2017-06-12 13:50:00 -04:00
|
|
|
|
InitializeTokens();
|
|
|
|
|
InitializeAutoMessages();
|
|
|
|
|
InitializeMaps();
|
|
|
|
|
InitializeRules();
|
2015-08-20 01:06:44 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Returns current server IP set by `net_ip` -- *STRING*
|
2017-06-12 13:50:00 -04:00
|
|
|
|
public String GetIP()
|
2015-08-20 01:06:44 -04:00
|
|
|
|
{
|
|
|
|
|
return IP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Returns current server port set by `net_port` -- *INT*
|
2017-06-12 13:50:00 -04:00
|
|
|
|
public int GetPort()
|
2015-08-20 01:06:44 -04:00
|
|
|
|
{
|
|
|
|
|
return Port;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Returns list of all current players
|
2017-06-07 20:59:59 -04:00
|
|
|
|
public List<Player> GetPlayersAsList()
|
2015-08-20 01:06:44 -04:00
|
|
|
|
{
|
2017-05-26 18:49:27 -04:00
|
|
|
|
return Players.FindAll(x => x != null);
|
2015-08-20 01:06:44 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-20 15:23:13 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Add a player to the server's player list
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="P">Player pulled from memory reading</param>
|
|
|
|
|
/// <returns>True if player added sucessfully, false otherwise</returns>
|
2017-05-26 18:49:27 -04:00
|
|
|
|
abstract public Task<bool> AddPlayer(Player P);
|
2015-08-20 01:06:44 -04:00
|
|
|
|
|
2015-08-20 15:23:13 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Remove player by client number
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="cNum">Client ID of player to be removed</param>
|
|
|
|
|
/// <returns>true if removal succeded, false otherwise</returns>
|
2017-05-26 18:49:27 -04:00
|
|
|
|
abstract public Task RemovePlayer(int cNum);
|
2015-08-20 01:06:44 -04:00
|
|
|
|
|
2015-08-20 15:23:13 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Get the player from the server's list by line from game long
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="L">Game log line containing event</param>
|
|
|
|
|
/// <param name="cIDPos">Position in the line where the cliet ID is written</param>
|
|
|
|
|
/// <returns>Matching player if found</returns>
|
2017-06-07 17:08:29 -04:00
|
|
|
|
abstract public Player ParseClientFromString(String[] L, int cIDPos);
|
2015-08-20 01:06:44 -04:00
|
|
|
|
|
2015-08-20 15:23:13 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Get a player by name
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="pName">Player name to search for</param>
|
|
|
|
|
/// <returns>Matching player if found</returns>
|
2017-11-16 18:09:19 -05:00
|
|
|
|
public List<Player> GetClientByName(String pName)
|
2015-08-20 01:06:44 -04:00
|
|
|
|
{
|
2017-06-16 17:35:51 -04:00
|
|
|
|
string[] QuoteSplit = pName.Split('"');
|
2017-11-16 18:09:19 -05:00
|
|
|
|
bool literal = false;
|
2017-06-16 17:35:51 -04:00
|
|
|
|
if (QuoteSplit.Length > 1)
|
2017-11-16 18:09:19 -05:00
|
|
|
|
{
|
2017-06-16 17:35:51 -04:00
|
|
|
|
pName = QuoteSplit[1];
|
2017-11-16 18:09:19 -05:00
|
|
|
|
literal = true;
|
|
|
|
|
}
|
|
|
|
|
if (literal)
|
|
|
|
|
return Players.Where(p => p != null && p.Name.ToLower().Equals(pName.ToLower())).ToList();
|
|
|
|
|
|
|
|
|
|
return Players.Where(p => p != null && p.Name.ToLower().Contains(pName.ToLower())).ToList();
|
2015-08-20 01:06:44 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-20 15:23:13 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Process requested command correlating to an event
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="E">Event parameter</param>
|
|
|
|
|
/// <param name="C">Command requested from the event</param>
|
|
|
|
|
/// <returns></returns>
|
2017-05-30 17:23:31 -04:00
|
|
|
|
abstract public Task<Command> ValidateCommand(Event E);
|
2015-08-20 01:06:44 -04:00
|
|
|
|
|
2018-02-07 00:19:06 -05:00
|
|
|
|
virtual public Task<bool> ProcessUpdatesAsync(CancellationToken cts)
|
2017-05-26 18:49:27 -04:00
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2017-10-15 21:40:27 -04:00
|
|
|
|
|
2015-08-20 15:23:13 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Process any server event
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="E">Event</param>
|
|
|
|
|
/// <returns>True on sucess</returns>
|
2017-05-26 18:49:27 -04:00
|
|
|
|
abstract protected Task ProcessEvent(Event E);
|
|
|
|
|
abstract public Task ExecuteEvent(Event E);
|
2015-08-20 01:06:44 -04:00
|
|
|
|
|
2015-08-20 15:23:13 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Reloads all the server configurations
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>True on sucess</returns>
|
2015-08-20 17:54:38 -04:00
|
|
|
|
abstract public bool Reload();
|
2015-08-20 01:06:44 -04:00
|
|
|
|
|
2015-08-20 15:23:13 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Send a message to all players
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Message">Message to be sent to all players</param>
|
2017-05-26 18:49:27 -04:00
|
|
|
|
public async Task Broadcast(String Message)
|
2015-08-20 01:06:44 -04:00
|
|
|
|
{
|
2018-02-08 02:23:45 -05:00
|
|
|
|
|
2017-08-08 22:44:52 -04:00
|
|
|
|
string sayCommand = (GameName == Game.IW4) ? "sayraw" : "say";
|
2018-02-08 02:23:45 -05:00
|
|
|
|
#if !DEBUG
|
2017-08-08 22:44:52 -04:00
|
|
|
|
await this.ExecuteCommandAsync($"{sayCommand} {Message}");
|
2018-02-08 02:23:45 -05:00
|
|
|
|
#else
|
|
|
|
|
Logger.WriteVerbose(Message.StripColors());
|
|
|
|
|
#endif
|
2015-08-20 01:06:44 -04:00
|
|
|
|
}
|
2017-05-26 18:49:27 -04:00
|
|
|
|
|
2015-08-20 15:23:13 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Send a message to a particular players
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Message">Message to send</param>
|
|
|
|
|
/// <param name="Target">Player to send message to</param>
|
2017-05-26 18:49:27 -04:00
|
|
|
|
public async Task Tell(String Message, Player Target)
|
2015-08-20 01:06:44 -04:00
|
|
|
|
{
|
2017-08-08 22:44:52 -04:00
|
|
|
|
string tellCommand = (GameName == Game.IW4) ? "tellraw" : "tell";
|
|
|
|
|
|
2018-02-08 02:23:45 -05:00
|
|
|
|
#if !DEBUG
|
2017-11-25 20:29:58 -05:00
|
|
|
|
if (Target.ClientNumber > -1 && Message.Length > 0 && Target.Level != Player.Permission.Console)
|
|
|
|
|
await this.ExecuteCommandAsync($"{tellCommand} {Target.ClientNumber} {Message}^7");
|
2018-02-08 02:23:45 -05:00
|
|
|
|
#else
|
|
|
|
|
Logger.WriteVerbose($"{Target.ClientNumber}->{Message.StripColors()}");
|
|
|
|
|
#endif
|
2015-08-22 02:04:30 -04:00
|
|
|
|
|
|
|
|
|
if (Target.Level == Player.Permission.Console)
|
|
|
|
|
{
|
|
|
|
|
Console.ForegroundColor = ConsoleColor.Cyan;
|
2017-05-26 18:49:27 -04:00
|
|
|
|
Console.WriteLine(Utilities.StripColors(Message));
|
2015-08-22 02:04:30 -04:00
|
|
|
|
Console.ForegroundColor = ConsoleColor.Gray;
|
|
|
|
|
}
|
2018-02-23 02:06:13 -05:00
|
|
|
|
if (CommandResult.Count > 15)
|
|
|
|
|
CommandResult.RemoveAt(0);
|
|
|
|
|
CommandResult.Add(new CommandResponseInfo()
|
2017-11-25 20:29:58 -05:00
|
|
|
|
{
|
2018-02-23 02:06:13 -05:00
|
|
|
|
Response = Utilities.StripColors(Message),
|
|
|
|
|
ClientId = Target.ClientId
|
2017-11-25 20:29:58 -05:00
|
|
|
|
});
|
2015-08-20 01:06:44 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-20 15:23:13 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Send a message to all admins on the server
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="message">Message to send out</param>
|
2017-05-26 18:49:27 -04:00
|
|
|
|
public async Task ToAdmins(String message)
|
2015-08-20 01:06:44 -04:00
|
|
|
|
{
|
2017-05-26 18:49:27 -04:00
|
|
|
|
foreach (Player P in Players)
|
2015-08-20 15:23:13 -04:00
|
|
|
|
{
|
2017-05-26 18:49:27 -04:00
|
|
|
|
if (P == null)
|
|
|
|
|
continue;
|
2015-08-20 15:23:13 -04:00
|
|
|
|
|
2017-05-26 18:49:27 -04:00
|
|
|
|
if (P.Level > Player.Permission.Flagged)
|
|
|
|
|
await P.Tell(message);
|
2015-08-20 15:23:13 -04:00
|
|
|
|
}
|
2015-08-20 01:06:44 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-20 15:23:13 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Kick a player from the server
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Reason">Reason for kicking</param>
|
|
|
|
|
/// <param name="Target">Player to kick</param>
|
2017-05-26 18:49:27 -04:00
|
|
|
|
abstract public Task Kick(String Reason, Player Target, Player Origin);
|
2015-08-20 01:06:44 -04:00
|
|
|
|
|
2015-08-20 15:23:13 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Temporarily ban a player ( default 1 hour ) from the server
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Reason">Reason for banning the player</param>
|
|
|
|
|
/// <param name="Target">The player to ban</param>
|
2017-08-23 18:29:48 -04:00
|
|
|
|
abstract public Task TempBan(String Reason, TimeSpan length, Player Target, Player Origin);
|
2015-08-20 01:06:44 -04:00
|
|
|
|
|
2015-08-20 15:23:13 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Perm ban a player from the server
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Reason">The reason for the ban</param>
|
|
|
|
|
/// <param name="Target">The person to ban</param>
|
|
|
|
|
/// <param name="Origin">The person who banned the target</param>
|
2017-05-26 18:49:27 -04:00
|
|
|
|
abstract public Task Ban(String Reason, Player Target, Player Origin);
|
2015-08-20 15:23:13 -04:00
|
|
|
|
|
2017-05-26 18:49:27 -04:00
|
|
|
|
abstract public Task Warn(String Reason, Player Target, Player Origin);
|
2016-01-16 17:58:24 -05:00
|
|
|
|
|
2015-08-20 15:23:13 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Unban a player by npID / GUID
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="npID">npID of the player</param>
|
|
|
|
|
/// <param name="Target">I don't remember what this is for</param>
|
|
|
|
|
/// <returns></returns>
|
2018-02-17 01:13:38 -05:00
|
|
|
|
abstract public Task Unban(string reason, Player Target, Player Origin);
|
2015-08-20 01:06:44 -04:00
|
|
|
|
|
2015-08-20 15:23:13 -04:00
|
|
|
|
/// <summary>
|
2017-05-26 18:49:27 -04:00
|
|
|
|
/// Change the current searver map
|
2015-08-20 15:23:13 -04:00
|
|
|
|
/// </summary>
|
2017-05-26 18:49:27 -04:00
|
|
|
|
/// <param name="mapName">Non-localized map name</param>
|
|
|
|
|
public async Task LoadMap(string mapName)
|
2015-08-20 01:06:44 -04:00
|
|
|
|
{
|
2017-05-26 18:49:27 -04:00
|
|
|
|
await this.ExecuteCommandAsync($"map {mapName}");
|
2015-08-20 01:06:44 -04:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-26 18:49:27 -04:00
|
|
|
|
public async Task LoadMap(Map newMap)
|
2015-08-20 01:06:44 -04:00
|
|
|
|
{
|
2017-05-26 18:49:27 -04:00
|
|
|
|
await this.ExecuteCommandAsync($"map {newMap.Name}");
|
2015-08-20 01:06:44 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-20 15:23:13 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initalize the macro variables
|
|
|
|
|
/// </summary>
|
2017-06-12 13:50:00 -04:00
|
|
|
|
abstract public void InitializeTokens();
|
2015-08-20 01:06:44 -04:00
|
|
|
|
|
2015-08-20 15:23:13 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Read the map configuration
|
|
|
|
|
/// </summary>
|
2017-06-12 13:50:00 -04:00
|
|
|
|
protected void InitializeMaps()
|
2015-08-20 01:06:44 -04:00
|
|
|
|
{
|
2017-06-19 13:58:01 -04:00
|
|
|
|
Maps = new List<Map>();
|
2015-08-20 01:06:44 -04:00
|
|
|
|
|
2018-02-21 20:29:23 -05:00
|
|
|
|
IFile mapfile = new IFile($"{Utilities.OperatingDirectory}config/maps.cfg");
|
2017-06-12 13:50:00 -04:00
|
|
|
|
String[] _maps = mapfile.ReadAllLines();
|
2015-08-20 01:06:44 -04:00
|
|
|
|
mapfile.Close();
|
|
|
|
|
if (_maps.Length > 2) // readAll returns minimum one empty string
|
|
|
|
|
{
|
|
|
|
|
foreach (String m in _maps)
|
|
|
|
|
{
|
|
|
|
|
String[] m2 = m.Split(':');
|
|
|
|
|
if (m2.Length > 1)
|
|
|
|
|
{
|
|
|
|
|
Map map = new Map(m2[0].Trim(), m2[1].Trim());
|
2017-06-19 13:58:01 -04:00
|
|
|
|
Maps.Add(map);
|
2015-08-20 01:06:44 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-10-15 21:40:27 -04:00
|
|
|
|
}
|
2015-08-20 01:06:44 -04:00
|
|
|
|
else
|
2017-05-27 19:29:20 -04:00
|
|
|
|
Logger.WriteInfo("Maps configuration appears to be empty - skipping...");
|
2015-08-20 01:06:44 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-20 15:23:13 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initialize the messages to be broadcasted
|
2017-06-12 13:50:00 -04:00
|
|
|
|
/// todo: this needs to be a serialized file
|
2015-08-20 15:23:13 -04:00
|
|
|
|
/// </summary>
|
2017-06-12 13:50:00 -04:00
|
|
|
|
protected void InitializeAutoMessages()
|
2015-08-20 01:06:44 -04:00
|
|
|
|
{
|
2017-06-19 13:58:01 -04:00
|
|
|
|
BroadcastMessages = new List<String>();
|
2015-08-20 01:06:44 -04:00
|
|
|
|
|
2018-02-21 20:29:23 -05:00
|
|
|
|
IFile messageCFG = new IFile($"{Utilities.OperatingDirectory}config/messages.cfg");
|
2017-06-12 13:50:00 -04:00
|
|
|
|
String[] lines = messageCFG.ReadAllLines();
|
2015-08-20 01:06:44 -04:00
|
|
|
|
messageCFG.Close();
|
|
|
|
|
|
|
|
|
|
if (lines.Length < 2) //readAll returns minimum one empty string
|
|
|
|
|
{
|
2017-05-27 19:29:20 -04:00
|
|
|
|
Logger.WriteInfo("Messages configuration appears empty - skipping...");
|
2015-08-20 01:06:44 -04:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int mTime = -1;
|
|
|
|
|
int.TryParse(lines[0], out mTime);
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
if (MessageTime == -1)
|
|
|
|
|
MessageTime = 60;
|
2015-08-20 01:06:44 -04:00
|
|
|
|
else
|
2017-06-19 13:58:01 -04:00
|
|
|
|
MessageTime = mTime;
|
2017-10-15 21:40:27 -04:00
|
|
|
|
|
2015-08-20 01:06:44 -04:00
|
|
|
|
foreach (String l in lines)
|
|
|
|
|
{
|
|
|
|
|
if (lines[0] != l && l.Length > 1)
|
2017-06-19 13:58:01 -04:00
|
|
|
|
BroadcastMessages.Add(l);
|
2015-08-20 01:06:44 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
messageCFG.Close();
|
|
|
|
|
|
|
|
|
|
//if (Program.Version != Program.latestVersion && Program.latestVersion != 0)
|
2017-10-15 21:40:27 -04:00
|
|
|
|
// messages.Add("^5IW4M Admin ^7is outdated. Please ^5update ^7to version " + Program.latestVersion);
|
2015-08-20 01:06:44 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-20 15:23:13 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initialize the rules configuration
|
2017-06-12 13:50:00 -04:00
|
|
|
|
/// todo: this needs to be a serialized file
|
2015-08-20 15:23:13 -04:00
|
|
|
|
/// </summary>
|
2017-06-12 13:50:00 -04:00
|
|
|
|
protected void InitializeRules()
|
2015-08-20 01:06:44 -04:00
|
|
|
|
{
|
2017-06-19 13:58:01 -04:00
|
|
|
|
Rules = new List<String>();
|
2015-08-20 01:06:44 -04:00
|
|
|
|
|
2018-02-21 20:29:23 -05:00
|
|
|
|
IFile ruleFile = new IFile($"{Utilities.OperatingDirectory}config/rules.cfg");
|
2017-06-12 13:50:00 -04:00
|
|
|
|
String[] _rules = ruleFile.ReadAllLines();
|
2015-08-20 01:06:44 -04:00
|
|
|
|
ruleFile.Close();
|
|
|
|
|
if (_rules.Length > 2) // readAll returns minimum one empty string
|
|
|
|
|
{
|
|
|
|
|
foreach (String r in _rules)
|
|
|
|
|
{
|
|
|
|
|
if (r.Length > 1)
|
2017-06-19 13:58:01 -04:00
|
|
|
|
Rules.Add(r);
|
2015-08-20 01:06:44 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2017-05-27 19:29:20 -04:00
|
|
|
|
Logger.WriteInfo("Rules configuration appears empty - skipping...");
|
2015-08-20 01:06:44 -04:00
|
|
|
|
|
|
|
|
|
ruleFile.Close();
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-02 12:49:45 -04:00
|
|
|
|
public ConfigurationManager Configuration { get; private set; }
|
|
|
|
|
|
2017-06-06 23:45:21 -04:00
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return $"{IP}_{Port}";
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-25 20:29:58 -05:00
|
|
|
|
protected async Task<bool> ScriptLoaded()
|
2017-11-02 12:49:45 -04:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return (await this.GetDvarAsync<string>("sv_customcallbacks")).Value == "1";
|
|
|
|
|
}
|
2017-11-25 20:29:58 -05:00
|
|
|
|
|
|
|
|
|
catch (Exceptions.DvarException)
|
2017-11-02 12:49:45 -04:00
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
// Objects
|
2017-05-26 18:49:27 -04:00
|
|
|
|
public Interfaces.IManager Manager { get; protected set; }
|
2017-05-27 19:29:20 -04:00
|
|
|
|
public Interfaces.ILogger Logger { get; private set; }
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public ServerConfiguration Config { get; private set; }
|
|
|
|
|
public List<Map> Maps { get; protected set; }
|
|
|
|
|
public List<string> Rules { get; protected set; }
|
2017-10-15 21:40:27 -04:00
|
|
|
|
public List<Report> Reports { get; set; }
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public List<Chat> ChatHistory { get; protected set; }
|
2017-06-12 17:47:31 -04:00
|
|
|
|
public Queue<Helpers.PlayerHistory> PlayerHistory { get; private set; }
|
2017-08-08 22:44:52 -04:00
|
|
|
|
public Game GameName { get; protected set; }
|
2015-08-20 01:06:44 -04:00
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
// Info
|
|
|
|
|
public string Hostname { get; protected set; }
|
|
|
|
|
public string Website { get; protected set; }
|
|
|
|
|
public string Gametype { get; protected set; }
|
2017-05-26 18:49:27 -04:00
|
|
|
|
public Map CurrentMap { get; protected set; }
|
2017-10-15 21:40:27 -04:00
|
|
|
|
public int ClientNum
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Players.Where(p => p != null).Count();
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-05-26 18:49:27 -04:00
|
|
|
|
public int MaxClients { get; protected set; }
|
|
|
|
|
public List<Player> Players { get; protected set; }
|
|
|
|
|
public string Password { get; private set; }
|
2017-08-09 00:35:23 -04:00
|
|
|
|
public bool Throttled { get; protected set; }
|
2017-11-02 12:49:45 -04:00
|
|
|
|
public bool CustomCallback { get; protected set; }
|
2018-03-06 02:22:19 -05:00
|
|
|
|
public string WorkingDirectory { get; protected set; }
|
2015-08-20 01:06:44 -04:00
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
// Internal
|
|
|
|
|
protected string IP;
|
|
|
|
|
protected int Port;
|
|
|
|
|
protected string FSGame;
|
|
|
|
|
protected int MessageTime;
|
|
|
|
|
protected int NextMessage;
|
|
|
|
|
protected int ConnectionErrors;
|
|
|
|
|
protected List<string> BroadcastMessages;
|
|
|
|
|
protected TimeSpan LastMessage;
|
|
|
|
|
protected IFile LogFile;
|
|
|
|
|
protected DateTime LastPoll;
|
2015-08-20 01:06:44 -04:00
|
|
|
|
|
2017-05-26 18:49:27 -04:00
|
|
|
|
//Remote
|
2018-02-23 02:06:13 -05:00
|
|
|
|
public IList<CommandResponseInfo> CommandResult = new List<CommandResponseInfo>();
|
2015-08-20 01:06:44 -04:00
|
|
|
|
}
|
|
|
|
|
}
|