Skip to content

Commit 6592119

Browse files
committed
Fixed potential game and server running errors
1 parent 13122bf commit 6592119

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

MainForm.cs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,24 @@ private void startProcess(string name)
357357
// Process.Start(pathToApp + "\\" + appExecutable, "-game " + FileSystem.Main.getModDirectory());
358358
Process process = new Process();
359359
ProcessStartInfo startInfo = new ProcessStartInfo();
360-
startInfo.WorkingDirectory = String.Format(@"{0}\{1}", gamePath, choosedMod);
361-
startInfo.FileName = String.Format(@"{0}\{1}", gamePath, name);
362-
startInfo.Arguments = String.Format("-game \"{0}\" {1}", choosedMod, ((name.Contains("hlds.exe")) ? srvParametersText.Text : gameParametersText.Text));
360+
361+
bool isHLDS = name.Contains("hlds.exe");
362+
363+
if (isHLDS)
364+
{
365+
Console.WriteLine("Running HLDS...");
366+
startInfo.WorkingDirectory = String.Format(@"{0}\bin", gamePath);
367+
startInfo.FileName = String.Format(@"{0}\bin\{1}", gamePath, name);
368+
startInfo.Arguments = String.Format("-game \"{0}\" {1}", choosedMod, srvParametersText.Text);
369+
}
370+
else
371+
{
372+
Console.WriteLine("Running HL2...");
373+
startInfo.WorkingDirectory = gamePath;
374+
startInfo.FileName = String.Format(@"{0}\{1}", gamePath, name);
375+
startInfo.Arguments = String.Format("-game \"{0}\" {1}", choosedMod, gameParametersText.Text);
376+
}
377+
363378
startInfo.CreateNoWindow = true;
364379
// MessageBox.Show(pathToApp + "; " + (pathToApp + "\\" + appExecutable) + "; " + ("-game " + FileSystem.Main.getModDirectory()));
365380
// Process.Start(startInfo);
@@ -409,14 +424,14 @@ private void gameStopButton_Click(object sender, EventArgs e)
409424

410425
private void srvStartButton_Click(object sender, EventArgs e)
411426
{
412-
startProcess( @"bin\hlds.exe" );
427+
startProcess( "hlds.exe" );
413428
}
414429

415430
private void srvParametersText_KeyDown(object sender, KeyEventArgs e)
416431
{
417432
if (e.KeyCode == Keys.Enter)
418433
{
419-
startProcess(@"bin\hlds.exe");
434+
startProcess("hlds.exe");
420435
}
421436
}
422437

0 commit comments

Comments
 (0)