Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit 0e55c67

Browse files
committed
advances in using valvequery from @Deathreus
1 parent ccce6e4 commit 0e55c67

File tree

9 files changed

+1722
-22
lines changed

9 files changed

+1722
-22
lines changed

QueryMaster/DotNetZip.dll

446 KB
Binary file not shown.

QueryMaster/Newtonsoft.Json.dll

647 KB
Binary file not shown.
41 KB
Binary file not shown.

QueryMaster/ValveQuery.dll

69 KB
Binary file not shown.

QueryMaster/ValveQuery.xml

Lines changed: 1687 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

QueryMaster/WebSocket4Net.dll

60.5 KB
Binary file not shown.

Spcode.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@
8888
<Reference Include="System.XML" />
8989
<Reference Include="System.Xml.Linq" />
9090
<Reference Include="UIAutomationProvider" />
91+
<Reference Include="ValveQuery">
92+
<HintPath>QueryMaster\ValveQuery.dll</HintPath>
93+
</Reference>
9194
<Reference Include="WindowsBase" />
9295
<Reference Include="WindowsFormsIntegration" />
9396
</ItemGroup>
@@ -549,6 +552,9 @@
549552
<PackageReference Include="Microsoft-WindowsAPICodePack-Shell">
550553
<Version>1.1.4</Version>
551554
</PackageReference>
555+
<PackageReference Include="NETStandard.Library">
556+
<Version>2.0.3</Version>
557+
</PackageReference>
552558
<PackageReference Include="Newtonsoft.Json">
553559
<Version>12.0.3</Version>
554560
</PackageReference>

UI/MainWindow/MainWindowSPCompiler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ private void ProcessCheckWorker()
516516
{
517517
EnableServerAnim.Begin();
518518
UpdateWindowTitle();
519+
LoggingControl.LogAction("Server started.", 2);
519520
});
520521
ServerProcess.WaitForExit();
521522
ServerProcess.Dispose();
@@ -526,8 +527,8 @@ private void ProcessCheckWorker()
526527
{
527528
DisableServerAnim.Begin();
528529
UpdateWindowTitle();
530+
LoggingControl.LogAction("Server stopped.", 2);
529531
}
530-
LoggingControl.LogAction("Server started.", 2);
531532
});
532533
}
533534
catch (Exception)

UI/MainWindow/MainWindowServerQuery.cs

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.Text;
44
using System.Threading.Tasks;
55
using System.Windows;
6-
using QueryMaster;
6+
using ValveQuery.GameServer;
77
using SPCode.Interop;
88

99
namespace SPCode.UI;
@@ -23,34 +23,40 @@ private void Server_Query()
2323
goto Dispatcher;
2424
}
2525

26-
output.Add("Sending commands...");
27-
2826
try
2927
{
30-
var type = EngineType.GoldSource;
31-
if (c.RConUseSourceEngine)
28+
using var server = ServerQuery.GetServerInstance(c.RConIP, c.RConPort, throwExceptions: true);
29+
var serverInfo = server.GetInfo();
30+
31+
if (serverInfo == null)
32+
{
33+
output.Add("No server found to send commands to.");
34+
goto Dispatcher;
35+
}
36+
37+
output.Add(serverInfo.Name);
38+
39+
if (!server.GetControl(c.RConPassword, false))
3240
{
33-
type = EngineType.Source;
41+
output.Add("Incorrect RCON password.");
42+
goto Dispatcher;
3443
}
3544

36-
using (var server = ServerQuery.GetServerInstance(type, c.RConIP, c.RConPort, null))
45+
output.Add("Sending commands...");
46+
47+
var cmds = ReplaceRconCMDVariables(c.RConCommands).Split('\n');
48+
49+
foreach (var cmd in cmds)
3750
{
38-
var serverInfo = server.GetInfo();
39-
output.Add(serverInfo.Name);
40-
using var rcon = server.GetControl(c.RConPassword);
41-
var cmds = ReplaceRconCMDVariables(c.RConCommands).Split('\n');
42-
foreach (var cmd in cmds)
51+
var t = Task.Run(() =>
4352
{
44-
var t = Task.Run(() =>
53+
var command = cmd.Trim('\r').Trim();
54+
if (!string.IsNullOrWhiteSpace(command))
4555
{
46-
var command = cmd.Trim('\r').Trim();
47-
if (!string.IsNullOrWhiteSpace(command))
48-
{
49-
output.Add(rcon.SendCommand(command));
50-
}
51-
});
52-
t.Wait();
53-
}
56+
server.Rcon.SendCommand(command);
57+
}
58+
});
59+
t.Wait();
5460
}
5561
output.Add("Commands sent.");
5662
}

0 commit comments

Comments
 (0)