Skip to content

Commit

Permalink
Fixed game and server parameters not being saved
Browse files Browse the repository at this point in the history
Fixed killing of HLDS processes
  • Loading branch information
UAVXP committed Apr 19, 2017
1 parent 6414879 commit 3ca41af
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
19 changes: 17 additions & 2 deletions MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ protected override CreateParams CreateParams
}

List<Mod> mods = new List<Mod>();
bool bFullyLoaded = false;

public MainForm()
{
Expand Down Expand Up @@ -171,6 +172,7 @@ public static bool setRegistryValue(string subkey, string value)
RegistryKey key = Registry.CurrentUser.CreateSubKey(getRegistryMainPath());
key.SetValue(subkey, value);
key.Close();
Console.WriteLine("Writing " + value + " at " + subkey);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -286,6 +288,7 @@ public void RefreshModList()
private void MainForm_Load(object sender, EventArgs e)
{
RefreshModList();
bFullyLoaded = true;
}

private void SaveAdditionalParameters()
Expand Down Expand Up @@ -329,7 +332,13 @@ private void additionalParamsBut_Click(object sender, EventArgs e)

private void parametersText_Leave(object sender, EventArgs e)
{
// Console.WriteLine("unfocused");
// Saving parameters into registry
SaveAdditionalParameters();
}

private void srvParametersText_Leave(object sender, EventArgs e)
{
// Saving parameters into registry
SaveAdditionalParameters();
}

Expand Down Expand Up @@ -360,13 +369,16 @@ private void startProcess(string name)
private void closeProcess(string name)
{
Process[] processes = Process.GetProcessesByName(name);
Console.WriteLine("Trying to kill " + name);
int procCount = processes.Length;
if (procCount > 0)
{
for (int i = 0; i < procCount; i++)
{
Console.WriteLine("\t" + Path.GetDirectoryName(processes[i].Modules[0].FileName));
// Close only process that exists aside program
bool bSamePath = Path.GetDirectoryName(processes[0].Modules[0].FileName).Equals(gamePath);
bool isHLDS = name.Contains("hlds");
bool bSamePath = Path.GetDirectoryName(processes[i].Modules[0].FileName).Equals(isHLDS ? gamePath + "\\bin" : gamePath);
if (bSamePath)
{
processes[i].Kill();
Expand Down Expand Up @@ -418,6 +430,9 @@ private void btnRefresh_Click(object sender, EventArgs e)

private void modList_TextChanged(object sender, EventArgs e)
{
if (!bFullyLoaded)
return;

// string choosedMod = (sender as ComboBox).SelectedItem.ToString();
string choosedMod = mods[modList.SelectedIndex].Dir;
setRegistryValue("LNGameMod", choosedMod);
Expand Down
1 change: 1 addition & 0 deletions MainForm.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3ca41af

Please sign in to comment.