diff --git a/Application/IW4MServer.cs b/Application/IW4MServer.cs
index 741e0f155..4594adfce 100644
--- a/Application/IW4MServer.cs
+++ b/Application/IW4MServer.cs
@@ -1036,7 +1036,7 @@ namespace IW4MAdmin
baseGameDirectory.IndexOfAny(Utilities.DirectorySeparatorChars) != -1;
bool baseGameIsRelative = baseGameDirectory.FixDirectoryCharacters()
- .Equals(gameDirectory.FixDirectoryCharacters(), StringComparison.InvariantCultureIgnoreCase);
+ .Equals(gameDirectory?.FixDirectoryCharacters() ?? "", StringComparison.InvariantCultureIgnoreCase);
// we want to see if base game is provided and it 'looks' like a directory
if (baseGameIsDirectory && !baseGameIsRelative)
@@ -1046,7 +1046,7 @@ namespace IW4MAdmin
if (string.IsNullOrWhiteSpace(modDirectory))
{
- logPath = Path.Combine(workingDirectory, gameDirectory, logFile);
+ logPath = Path.Combine(workingDirectory, gameDirectory ?? "", logFile);
}
else
diff --git a/IW4MAdmin.sln b/IW4MAdmin.sln
index 5550abe48..a71beb5f3 100644
--- a/IW4MAdmin.sln
+++ b/IW4MAdmin.sln
@@ -40,6 +40,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ScriptPlugins", "ScriptPlug
ProjectSection(SolutionItems) = preProject
Plugins\ScriptPlugins\ParserCoD4x.js = Plugins\ScriptPlugins\ParserCoD4x.js
Plugins\ScriptPlugins\ParserIW4x.js = Plugins\ScriptPlugins\ParserIW4x.js
+ Plugins\ScriptPlugins\ParserPIW5.js = Plugins\ScriptPlugins\ParserPIW5.js
Plugins\ScriptPlugins\ParserPT6.js = Plugins\ScriptPlugins\ParserPT6.js
Plugins\ScriptPlugins\ParserRektT5M.js = Plugins\ScriptPlugins\ParserRektT5M.js
Plugins\ScriptPlugins\ParserTeknoMW3.js = Plugins\ScriptPlugins\ParserTeknoMW3.js
diff --git a/SharedLibraryCore/Dtos/IW4MAdminInfo.cs b/SharedLibraryCore/Dtos/IW4MAdminInfo.cs
index 835ca8bcd..382c5992f 100644
--- a/SharedLibraryCore/Dtos/IW4MAdminInfo.cs
+++ b/SharedLibraryCore/Dtos/IW4MAdminInfo.cs
@@ -1,6 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
+using static SharedLibraryCore.Server;
namespace SharedLibraryCore.Dtos
{
@@ -10,5 +8,15 @@ namespace SharedLibraryCore.Dtos
public int RecentClientCount { get; set; }
public int TotalOccupiedClientSlots { get; set; }
public int TotalAvailableClientSlots { get; set; }
+
+ ///
+ /// specifies the game name filter
+ ///
+ public Game? Game { get; set; }
+
+ ///
+ /// collection of unique game names being monitored
+ ///
+ public Game[] ActiveServerGames { get; set; }
}
}
diff --git a/WebfrontCore/Controllers/HomeController.cs b/WebfrontCore/Controllers/HomeController.cs
index af7f3e90c..1b9bf43ca 100644
--- a/WebfrontCore/Controllers/HomeController.cs
+++ b/WebfrontCore/Controllers/HomeController.cs
@@ -6,6 +6,7 @@ using SharedLibraryCore.Interfaces;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
+using static SharedLibraryCore.Server;
namespace WebfrontCore.Controllers
{
@@ -15,18 +16,22 @@ namespace WebfrontCore.Controllers
{
}
- public async Task Index()
+ public async Task Index(Game? game = null)
{
ViewBag.Description = "IW4MAdmin is a complete server administration tool for IW4x.";
ViewBag.Title = Localization["WEBFRONT_HOME_TITLE"];
ViewBag.Keywords = "IW4MAdmin, server, administration, IW4x, MW2, Modern Warfare 2";
+ var servers = Manager.GetServers().Where(_server => !game.HasValue ? true : _server.GameName == game);
+
var model = new IW4MAdminInfo()
{
- TotalAvailableClientSlots = Manager.GetServers().Sum(_server => _server.MaxClients),
- TotalOccupiedClientSlots = Manager.GetActiveClients().Count,
+ TotalAvailableClientSlots = servers.Sum(_server => _server.MaxClients),
+ TotalOccupiedClientSlots = servers.SelectMany(_server => _server.GetClientsAsList()).Count(),
TotalClientCount = await Manager.GetClientService().GetTotalClientsAsync(),
- RecentClientCount = await Manager.GetClientService().GetRecentClientCount()
+ RecentClientCount = await Manager.GetClientService().GetRecentClientCount(),
+ Game = game,
+ ActiveServerGames = Manager.GetServers().Select(_server => _server.GameName).Distinct().ToArray()
};
return View(model);
diff --git a/WebfrontCore/ViewComponents/ServerListViewComponent.cs b/WebfrontCore/ViewComponents/ServerListViewComponent.cs
index 25d97d00f..224692ff0 100644
--- a/WebfrontCore/ViewComponents/ServerListViewComponent.cs
+++ b/WebfrontCore/ViewComponents/ServerListViewComponent.cs
@@ -3,14 +3,15 @@ using SharedLibraryCore;
using SharedLibraryCore.Dtos;
using System.Linq;
using System.Net;
+using static SharedLibraryCore.Server;
namespace WebfrontCore.ViewComponents
{
public class ServerListViewComponent : ViewComponent
{
- public IViewComponentResult Invoke()
+ public IViewComponentResult Invoke(Game? game)
{
- var servers = Program.Manager.GetServers();
+ var servers = Program.Manager.GetServers().Where(_server => !game.HasValue ? true : _server.GameName == game);
var serverInfo = servers.Select(s => new ServerInfo()
{
diff --git a/WebfrontCore/Views/Home/Index.cshtml b/WebfrontCore/Views/Home/Index.cshtml
index f523f6a3a..47357f40d 100644
--- a/WebfrontCore/Views/Home/Index.cshtml
+++ b/WebfrontCore/Views/Home/Index.cshtml
@@ -19,7 +19,23 @@
-@await Component.InvokeAsync("ServerList")
+@if (Model.ActiveServerGames.Length > 1)
+{
+
+}
+
+@await Component.InvokeAsync("ServerList", Model.Game)
@section scripts {